This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/79319] sizeof returns the wrong size of a union containing aligned members
- From: "glisse at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 01 Feb 2017 09:36:54 +0000
- Subject: [Bug c/79319] sizeof returns the wrong size of a union containing aligned members
- Auto-submitted: auto-generated
- References: <bug-79319-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79319
--- Comment #3 from Marc Glisse <glisse at gcc dot gnu.org> ---
It is a bit confusing indeed that vec4_t has sizeof: 16 and _Alignof: 32, one
might expect an invariant that sizeof >= _Alignof... But just a typedef doesn't
increase the size, while stuffing it in a struct/union does. And indeed if I
try to make an array of vec4_t, I get the error: alignment of array elements is
greater than element size. clang gives the same output on your program, and
seems to ignore alignment if I make an array of vec4_t.