[Bug c/105588] _Alignof (C) and alignof (C++) on dereference of `double *` disagree on 32-bit x86
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105588 --- Comment #4 from Hubert Tong --- (In reply to Jakub Jelinek from comment #3) > _Alignof(expression) works like __alignof__(expression) which works like > __alignof__(__typeof(expression)), while _Alignof(type_name) is mandated by > the standard to work differently. Except it doesn't work that way. `__alignof__(expression)` is sensitive to what the expression is in ways other than its type: https://godbolt.org/z/GjETGnaGn ``` struct A { double d; } a; void f() { extern char x[__alignof__(__typeof(a.d))]; char (*y)[_Alignof(a.d)] = // warns } ``` So, if it cares what the expression refers to, then when what is referred to is unknown, the question becomes what `_Alignof` means: Is it the guaranteed alignment (of what you were given) or the preferred alignment (for what you might allocate)? `_Alignof` already means "guaranteed alignment" in `_Alignof(type)`. > The difference is that in the ia32 psABI, double is normally 8 byte aligned, > except when inside of struct/union where the alignment is lowered to 4 byte > alignment. > Changing any of this would be a significant ABI change. There is no request here to change the result of the actual allocation used for layout or allocation purposes. Just a request to make GNU C's `_Alignof(expression)` consistent with GNU C++'s `alignof(expression)` (both being GNU extensions).
[Bug c/105588] _Alignof (C) and alignof (C++) on dereference of `double *` disagree on 32-bit x86
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105588 Jakub Jelinek changed: What|Removed |Added CC||jakub at gcc dot gnu.org --- Comment #3 from Jakub Jelinek --- _Alignof(expression) works like __alignof__(expression) which works like __alignof__(__typeof(expression)), while _Alignof(type_name) is mandated by the standard to work differently. The difference is that in the ia32 psABI, double is normally 8 byte aligned, except when inside of struct/union where the alignment is lowered to 4 byte alignment. Changing any of this would be a significant ABI change.
[Bug c/105588] _Alignof (C) and alignof (C++) on dereference of `double *` disagree on 32-bit x86
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105588 --- Comment #2 from Hubert Tong --- (In reply to Andrew Pinski from comment #1) > _Alignof(expression) is still an extension it can return what ever GCC > decides Sure, although why GCC should have corresponding C and C++ extensions that behave differently from each other is a bit of a mystery here.
[Bug c/105588] _Alignof (C) and alignof (C++) on dereference of `double *` disagree on 32-bit x86
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105588 --- Comment #1 from Andrew Pinski --- _Alignof(expression) is still an extension it can return what ever GCC decides