[Bug c++/69089] New: C++11: alignas(0) causes an error
vogt at linux dot vnet.ibm.com
gcc-bugzilla@gcc.gnu.org
Wed Dec 30 14:32:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69089
Bug ID: 69089
Summary: C++11: alignas(0) causes an error
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: vogt at linux dot vnet.ibm.com
CC: krebbel at gcc dot gnu.org
Target Milestone: ---
Target: x86_64 s390
Created attachment 37193
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37193&action=edit
Fix for gcc-6.0.0
The c++11 standard demands that "alignas(0)" is valid but ignored:
"— if the constant expression evaluates to zero, the alignment
specifier shall have no effect"
However, g++ generates an error instead:
-- foo.c --
alignas(0) int x;
-- foo.c --
# x86 with gcc-6.0
$ g++ S -std=c++11 foo.c
foo.c:1:16: error: requested alignment is not a positive power of 2
alignas(0) int x;
Same on s390 with gcc-5.2.
The error is generated in check_user_alignment(). The bug seems to be that
"alignas(0)" generates an "align" attribute instead of being silently removed.
More information about the Gcc-bugs
mailing list