https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84027

            Bug ID: 84027
           Summary: new-expression does not accept an
                    attribute-specifier-seq
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: smw at gcc dot gnu.org
  Target Milestone: ---

The standard [expr.new]/1 defines the new-type-id part of a new expression as
having (one or more) attribute-specifier-seq but GCC does not accept that
construct.  Example code:

    void f() { char* p = new char[sizeof(int)] alignas(int); }

GCC 8.0.1 20180117 (exprimental) with -std=c++14 -pedantic gives the following
diagnostic.

<source>: In function 'void f()':
1 : <source>:1:44: error: expected ',' or ';' before 'alignas'
 void f() { char* p = new char[sizeof(int)] alignas(int); }
                                            ^~~~~~~
1 : <source>:1:18: warning: unused variable 'p' [-Wunused-variable]
 void f() { char* p = new char[sizeof(int)] alignas(int); }
                  ^
Note that the example code is accepted without error by clang and ICC.

Reply via email to