public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: MinGW x86_64 ABI problem
@ 2009-02-24 12:45 Joern Rennecke
  2009-02-24 13:30 ` John Fine
  0 siblings, 1 reply; 7+ messages in thread
From: Joern Rennecke @ 2009-02-24 12:45 UTC (permalink / raw)
  To: John Fine; +Cc: gcc-help

> 1) Can you tell me where callee saved registers are specified in the gcc source code.

To a first order of approximation, that's the CALL_USED_REGS macro in
tm.h (config/i386/i386.h).
But it can get refined in other places, as in this case in
CONDITIONAL_REGISTER_USAGE.   Some ports also use OVERRIDE_OPTIONS,
for mainly historical reasons.

> 2) I tried adding "-f-call-saved-xmm9" to the g++ command to see if that would fix the problem for one register. That compile aborted with
> internal compiler error: in copyprop_hardreg_forward_1, at regrename.c:1590
> Is that switch so incorrect? I understand it would generate .obj code incompatible with anything generated without that switch. But why should it crash gcc?

Different registers need to be copied in different ways.  If a port does
not anticipate that a certain register class may need saving, the generic
code to implement saving of registers across calls can emit instructions
that can not be recognized, so that code like:

      extract_insn (insn);
      if (! constrain_operands (1))
        fatal_insn_not_found (insn);

will abort.

You'd have to fix the machine description to recognize and implement properly
these register saves and restores.  And then you'll have to recompile
all the libraries with your changed ABI.

If you only have a few entry points in your DLL, it might be simpler
to write some wrapper code in assembler to save and restore the xmm
registers.

^ permalink raw reply	[flat|nested] 7+ messages in thread
* friendly operator overloading
@ 2009-02-23 15:10 Bernd Prager
  2009-02-23 16:14 ` Axel Freyn
  0 siblings, 1 reply; 7+ messages in thread
From: Bernd Prager @ 2009-02-23 15:10 UTC (permalink / raw)
  To: gcc-help

Hi,

I need some help with operator overloading.
Following test program compiles and runs fine with g++ (GCC) 4.1.2:

#include <iostream>
#include <string>

namespace xxx
{
class Container
{
friend std::ostream &operator<<(std::ostream&, const Container&);
private:
    int id;
    std::string s;
public:
    Container() : s("Hello World") {}
};


std::ostream &operator<<(std::ostream &stream, const Container &c)
{
    return std::cout << c.s << std::endl;
}
} // namespace

using namespace xxx;
int main()
{
    Container* c = new Container();

    std::cout << *c;

    return 0;
}

As long as I use it one (!) source file.

When I separate the Container class in separate Container.h and a
Container.cpp files the compiler complains about:
$ g++  -march=pentium4 -mfpmath=sse   tst.cpp container.cpp container.h  
-o tst
container.h: In function ‘std::ostream& operator<<(std::ostream&, const
xxx::Container&)’:
container.h:13: error: ‘std::string xxx::Container::s’ is private
container.cpp:8: error: within this context
make: *** [tst] Error 1

When I was trying to find out what is going on, I just put s into public.
Then I get the error message:

$ g++  -march=pentium4 -mfpmath=sse   tst.cpp container.cpp container.h  
-o tst
/tmp/ccCAgEWK.o: In function `main':
tst.cpp:(.text+0xb3): undefined reference to
`xxx::operator<<(std::basic_ostream<char, std::char_traits<char> >&,
xxx::Container const&)'
collect2: ld returned 1 exit status
make: *** [tst] Error 1

What makes me believe that there is some trouble with the namespace of the
operator<< definition, but only if I use separate files.

Anybody has any suggestion?

Thank you very much for any help,
-- Bernd

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-02-24 18:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-24 12:45 MinGW x86_64 ABI problem Joern Rennecke
2009-02-24 13:30 ` John Fine
2009-02-24 14:00   ` Joern Rennecke
  -- strict thread matches above, loose matches on Subject: below --
2009-02-23 15:10 friendly operator overloading Bernd Prager
2009-02-23 16:14 ` Axel Freyn
2009-02-23 22:33   ` MinGW x86_64 ABI problem John Fine
2009-02-24 17:00     ` NightStrike
2009-02-24 17:35       ` John Fine
2009-02-24 18:26         ` NightStrike

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).