NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: standards/52571 (max_align_t has smaller alignment than double)
Synopsis: max_align_t has smaller alignment than double
State-Changed-From-To: open->closed
State-Changed-By: riastradh%NetBSD.org@localhost
State-Changed-When: Mon, 09 Sep 2024 11:44:47 +0000
State-Changed-Why:
This is a bizarre quirk of gcc's __alignof__ extension, not NetBSD's
fault. Use the standard _Alignof instead. For example, compare the
sizes of symbols from the following definitions:
char gcc_alignof_double[__alignof__(double)];
char gcc_alignof_uniondouble[__alignof__(union { double x; })];
char stdc_alignof_double[_Alignof(double)];
char stdc_alignof_uniondouble[_Alignof(union { double x; })];
When I compile this with i386 gcc -std=c11 and dump the symbols with
`readelf -s', I get:
Num: Value Size Type Bind Vis Ndx Name
...
2: 00000000 8 OBJECT GLOBAL DEFAULT 3 gcc_alignof_double
3: 00000008 4 OBJECT GLOBAL DEFAULT 3 gcc_alignof_uniondouble
4: 0000000c 4 OBJECT GLOBAL DEFAULT 3 stdc_alignof_double
5: 00000010 4 OBJECT GLOBAL DEFAULT 3 stdc_alignof_uniondouble
Whatever gcc's __alignof__ gives you is not the required alignment: if
it were, it would have to agree with the plain double and the
union-of-double cases, but it doesn't.
Home |
Main Index |
Thread Index |
Old Index