Alignas broken when used with constexpr array data member for structure
Mason
slash.tmp@free.fr
Tue Jan 9 14:26:00 GMT 2018
On 09/01/2018 14:39, Alec Teal wrote:
> In GCC 4.8.4 I have something like the following:
FWIW, 4.8 is no longer supported (2013)
> constexpr int x = 5;
> constexpr int y = 4;
> struct alignas(y) my_data_block {
> char data[x];
> };
>
>
> And it causes some weird errors to the tune of "size of array 'data' is
> not an integral constant-expression" in the presence of the alignas
A good support request should specify
- exact compiler version (GCC 4.8.4)
- a small testcase (given above)
- exact compilation flags (missing)
- exact error message
Compiling the above source on godbolt using:
gcc 4.8.4 -Wall -Wextra
1 : <source>:1:1: warning: identifier 'constexpr' is a keyword in C++11 [-Wc++0x-compat]
constexpr int x = 5;
^
1 : <source>:1:1: error: 'constexpr' does not name a type
1 : <source>:1:1: note: C++11 'constexpr' only available with -std=c++11 or -std=gnu++11
2 : <source>:2:1: error: 'constexpr' does not name a type
constexpr int y = 4;
^
2 : <source>:2:1: note: C++11 'constexpr' only available with -std=c++11 or -std=gnu++11
3 : <source>:3:19: error: expected initializer before 'my_data_block'
struct alignas(y) my_data_block {
^
Compiler returned: 1
Compiling the above source on godbolt using:
gcc 4.8.4 -Wall -Wextra -std=c++11
No errors.
So it seems I can't reproduce the issue?
Looking at Bugzilla as jwakely suggested turns up
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58601
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70124
Regards.
More information about the Gcc-help
mailing list