[Bug c++/79024] New: alignas / alignof report wrong alignment for 64bit integer types for 32bit target
gnu-9fbaow at upsuper dot org
gcc-bugzilla@gcc.gnu.org
Sun Jan 8 00:28:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79024
Bug ID: 79024
Summary: alignas / alignof report wrong alignment for 64bit
integer types for 32bit target
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: gnu-9fbaow at upsuper dot org
Target Milestone: ---
See the following code:
#include <cstddef>
#include <cstdint>
struct Test1 { char c; uint64_t u; };
struct Test2 { char c; alignas(uint64_t) uint64_t u; };
static_assert(sizeof(Test1) == sizeof(Test2), "Size should be same, no?");
static_assert(offsetof(Test1, u) == offsetof(Test2, u),
"Offset should be same, no?");
Compiling this code with "g++ -m32", both static assertions are broken, which
indicates that uint64_t in Test1 is not aligned as what alignas reports.
FWIW, MSVC doesn't have this issue but clang has exactly the same issue.
More information about the Gcc-bugs
mailing list