https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99557
Bug ID: 99557
Summary: [AIX] Alignment of double for struct and C++ classes
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Keywords: ABI
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: dje at gcc dot gnu.org
Target Milestone: ---
Target: powerpc-ibm-aix*
The AIX power alignment rules apply the natural alignment of the
"first member" if it is of a floating-point data type (or is an aggregate
whose recursively "first" member or element is such a type). The alignment
associated with these types for subsequent members use an alignment value
where the floating-point data type is considered to have 4-byte alignment.
For the purposes of the foregoing: vtable pointers, non-empty base classes,
and zero-width bit-fields count as prior members; members of empty class
types marked no_unique_address are not considered to be prior members.
GCC mostly follows this rule, but there are some corner cases that continue to
not conform.
extern "C" int printf(const char *, ...);
struct N {
double d;
};
struct S {
N n;
float f;
};
struct T {
char c;
S s;
};
int main() {
printf("__builtin_offsetof(T, s): %lu\n", __builtin_offsetof(T, s));
return 0;
}
XL: 4
GCC: 8 ***
struct A {
double x;
};
typedef struct B {
int x;
struct A a;
} B;
int main() {
printf("__builtin_offsetof(B, a): %lu\n", __builtin_offsetof(B, a));
return 0;
}
XL: 4
GCC: 4
struct A {
double x;
A(const A &);
};
struct B {
int x;
A a;
};
int main() {
printf("__builtin_offsetof(B, a): %lu\n", __builtin_offsetof(B, a));
return 0;
}
XL: 4
GCC: 8 ***
Without the copy constructor, GCC conforms to the ABI.