c++/5805: [parser] the expression 'new (int*)[10]' should be a syntax error
Moritz Franosch
jfranosc@physik.tu-muenchen.de
Wed Mar 6 02:28:00 GMT 2002
rodrigc@gcc.gnu.org writes:
> Old Synopsis: the expression 'new (int*)[10]' should be a syntax error
> New Synopsis: [parser] the expression 'new (int*)[10]' should be a syntax error
>
> State-Changed-From-To: closed->analyzed
> State-Changed-By: rodrigc
> State-Changed-When: Tue Mar 5 18:45:52 2002
> State-Changed-Why:
> For the following testcase, bug.c:
> int main() {
> int** p;
> p = new int* [10];
> p = new (int*) [10];
> }
>
> If compiled with:
> g++ bug.cc -> NO ERROR
>
> If compiled with
> g++ -pedantic-errors bug.cc
> bug.cc:ISO C++ forbids array dimensions with parenthesized type in new
>
>
> This is apparently a gcc extension.
Sorry, I didn't think it could be an extension (although the behaviour
of g++ in this case seemed logical to me and I've always used it),
will better use '-pedantic' in the future.
So Intel C++ 5.0.4 didn't get it right (if compiled with -ansi Intel reports
an error instead of a warning, but the error is still the wrong
error), but g++ did. Very good, g++-team!
Thank you for your support.
Moritz
More information about the Gcc-bugs
mailing list