[Bug target/52023] _Alignof (double) yields wrong value on x86

eggert at gnu dot org gcc-bugzilla@gcc.gnu.org
Fri Jan 27 22:39:00 GMT 2012


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

eggert at gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|DUPLICATE                   |

--- Comment #8 from eggert at gnu dot org 2012-01-27 22:13:13 UTC ---
> What happens if you have the attribute packed on the structure?

That's not relevant to the standard conformance issue.
Any program that uses __attribute__((packed)) is not a C11 program,
and for such programs C11 does not specify what alignof(double) returns.
The most useful thing for alignof to return is the value that it would return
ignoring the presence of 'packed', as that makes its behavior
simpler and more consistent.  Most likely, if a future version of
C11 specifies structure packing, it'll specify precisely this behavior
for alignof, as it wouldn't be useful to have alignof(X) always return 1.

For strict C11 programs, though, _Alignof(double) cannot return 8 on x86 hosts,
because GCC sometimes allocate 'double' objects on boundaries that
are merely multiples of 4.  The test programs in comment#1 are strict
C11 programs and illustrate the conformance bug.



More information about the Gcc-bugs mailing list