------- Additional Comments From pinskia at gcc dot gnu dot org  2004-12-01 
18:56 -------
The problem has nothing to do with enums at all but doubles, if the double is 
the second element in 
the union it works.  I do know that that would be correct for structs but I 
forgot about the rules for 
unions.  Darwin uses the same rule as AIX uses for alignment so it is also a 
problem there too if this is 
a bug (someone will have to look it up).

In 4.0.0 we get:
Alignment of AlignA = 8
Alignment of AlignB = 4

which is what I had expected with my explaination about.

This gives the same output as the enum case (to show it has nothing to do with 
enums):
extern "C" int printf (const char*, ...);

union A {
  double d;
};

union B {
  int i;
  double d;
};

struct AlignA {
  char c;
  A a;
};

struct AlignB {
  char c;
  B b;
};

int main () {
  printf ("Alignment of AlignA = %d\n", __alignof__ (AlignA));
  printf ("Alignment of AlignB = %d\n", __alignof__ (AlignB));
}

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
 GCC target triplet|powerpc-apple-darwin7.4.0   |ppc-darwin, ppc-aix
           Keywords|                            |ABI, wrong-code
            Summary|C++ ABI bug on OS X with    |C++ ABI bug on OS X with
                   |enums                       |doubles


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18761

Reply via email to