public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: Mason <slash.tmp@free.fr>
Cc: Alec Teal <a.teal@warwick.ac.uk>, GCC help <gcc-help@gcc.gnu.org>
Subject: Re: Alignas broken when used with constexpr array data member for structure
Date: Tue, 09 Jan 2018 14:29:00 -0000	[thread overview]
Message-ID: <CAH6eHdTpoSdmjWRU3U8Z0wqh+SN383iyf8wyJwRyRCs-89hfYA@mail.gmail.com> (raw)
In-Reply-To: <9e28e812-5e74-efb1-8f4e-d2bb6ed7e7c3@free.fr>

On 9 January 2018 at 14:26, Mason wrote:
> 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

Don't give a help vampire a direct answer, see
http://slash7.com/2006/12/22/vampires/

You just enable their bad behaviour.

  reply	other threads:[~2018-01-09 14:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <2182301d-14b8-287d-bf6b-d9ed22e34726@warwick.ac.uk>
2018-01-09 13:39 ` Fwd: [X-POST] " Alec Teal
2018-01-09 13:41   ` Jonathan Wakely
2018-01-09 13:49     ` Alec Teal
2018-01-09 13:56       ` Jonathan Wakely
2018-01-09 14:04         ` Alec Teal
2018-01-09 14:06           ` Jonathan Wakely
2018-01-09 14:26   ` Mason
2018-01-09 14:29     ` Jonathan Wakely [this message]
2018-01-12 16:50     ` Alec Teal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAH6eHdTpoSdmjWRU3U8Z0wqh+SN383iyf8wyJwRyRCs-89hfYA@mail.gmail.com \
    --to=jwakely.gcc@gmail.com \
    --cc=a.teal@warwick.ac.uk \
    --cc=gcc-help@gcc.gnu.org \
    --cc=slash.tmp@free.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).