[Bug c++/88362] attribute aligned silently ignored on C++ references
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Dec 5 17:49:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88362
--- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> ---
I think the attribute on references needs to work the same way as on pointers
so that we get consistent behavior for reference members. __alignof__ should
return the corresponding alignment. For example, in the following all three
members are 32-byte aligned as expected:
struct S {
__attribute__ ((aligned (32))) int i;
__attribute__ ((aligned (32))) int *p;
__attribute__ ((aligned (32))) int &r;
};
S s = { 0, &s.i, s.i };
but in the following the last assertion fails with GCC (it passes with Clang):
static_assert (__alignof__ (s.i) == 32);
static_assert (__alignof__ (s.p) == 32);
static_assert (__alignof__ (s.r) == 32);
More information about the Gcc-bugs
mailing list