This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/59682] New: Invalid syntax accepted: new-placement without expression-list


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59682

            Bug ID: 59682
           Summary: Invalid syntax accepted: new-placement without
                    expression-list
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: frankhb1989 at gmail dot com

Minimal case:

int main()
{
int* p = new() int;
}

This should be invalid because as per the standard(ISO C++98/03/11) or the
current working draft of the standard(WG21/N3797), a new-placement should not
be '()':


[expr.new]/1
...
new-placement:
( expression-list )
...

There is no "opt" like "postfix-expression ( expression-list opt)", etc. And
the expression-list itself should be also a non-empty sequence of tokens.

G++ silently accepts the invalid code with or without
-pedantic-errors/-std=c++98/-std=c++03/-std=++11/-std=c++1y.

However, Clang++(trunk) rejects it correctly:

a.cc:4:14: error: expected expression
int* p = new() int;
             ^
1 error generated.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]