This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
4.0 regression: g++ class layout on PPC32 has changed
- From: Andrew Haley <aph at redhat dot com>
- To: gcc at gcc dot gnu dot org
- Date: Mon, 4 Apr 2005 16:07:49 +0100
- Subject: 4.0 regression: g++ class layout on PPC32 has changed
I've had a gcj bug report saying that some CNI code has ceased to work
on PPC 32, but I'm not sure that this is a gcj bug at all. The bug is
that gcj and g++ no longer have comptabile class layout -- members are
at different offsets.
If you run the appended code with g++ version 3.4.1, you get
$ g++ -m32 thing.cc -save-temps && ./a.out
56
With 4.0, you get
$ PATH=/local/aph/install/bin/:$PATH g++ -m32 thing.cc -save-temps -fabi-version=0 && ./a.out
52
So, apparently class layout has changed, but there doesn't seem to be
anything I can do with -fabi-version= to match the layout of the 3.4.1
compiler.
Does anyone understand what is going on here?
Thanks,
Andrew.
#include <stdio.h>
namespace java
{
namespace lang
{
class Object;
}
}
namespace x
{
class Parent;
class Child$Nested;
class Child;
}
class java::lang::Object
{
protected:
virtual void finalize (void) { }
public:
Object (void) { }
};
class x::Parent : public ::java::lang::Object
{
public:
Parent () { }
public:
long long __attribute__((aligned(__alignof__( ::java::lang::Object )))) l;
long long m;
long long o;
long long p;
long long q;
public:
void *scratch;
};
class x::Child$Nested : public ::x::Parent
{
public:
virtual void f ();
Child$Nested (::x::Child *);
private:
::x::Child * __attribute__((aligned(__alignof__( ::x::Parent )))) this$0;
public:
bool b;
friend class x_Child$Nested;
};
void
x::Child$Nested::f ()
{
printf ("%d\n", ((char*)&(this$0) - (char*)this));
}
::x::Child$Nested::Child$Nested(x::Child* p)
{
this$0 = p;
}
int main (int argc, char **argv)
{
::x::Child$Nested inst ((::x::Child *)NULL);
inst.f ();
return 0;
}