This program does not give the same alignment for A and B, which is very weird,
since the only difference is that B contains a declaration of a nested type. 
The culprit here is the Darwin round_type_align code.  I do not know if this bug
still occurs with GCC 4.0.

extern "C" int printf (const char*, ...);

union A {
  double d;
};

union B {
  enum E { e };
  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));
}

-- 
           Summary: C++ ABI bug on OS X with enums
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mmitchel at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: powerpc-apple-darwin7.4.0


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

Reply via email to