I have the following code that compiles without warnings with g++ 3.3.2 (x86-pc-linux) and 3.3.1 (mipsel-linux). But I get an error under 3.4. Not being a C++ expert, can someone tell me if my code is bogus, or if this is a problem with 3.4. Here is the code: ----------d1.cpp--------8<------------------------ char ** f1() { char** pSections; // allocate an array of 10 char pointers. pSections = new (char*)[10]; return pSections; } ---------------8<---------------------------- These are the errors: [daney@dl junk]$ mipsel-linux-g++ --version mipsel-linux-g++ (GCC) 3.4.0 20040214 (prerelease) Copyright (C) 2004 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. [daney@dl junk]$ mipsel-linux-g++ -c d1.cpp d1.cpp: In function `char** f1()': d1.cpp:7: error: expected `;' before '[' token Perhaps it should say something like: Parenthesized type name no longer allowed in new type[] expressions...
Confirmed, normal priority as per Joe Buck's request. Not a regression, but let me set a target on 3.4.0 anyway. I'll take care of thss, but I don't know if the patch will be feasable for the 3.4 branch. Let's see how intrusive it turns out to be.
Patch submitted: http://gcc.gnu.org/ml/gcc-patches/2004-02/msg01610.html
Subject: Bug 14181 CVSROOT: /cvs/gcc Module name: gcc Changes by: giovannibajo@gcc.gnu.org 2004-02-19 03:06:10 Modified files: gcc/cp : ChangeLog parser.c Log message: PR c++/14181 * parser.c (cp_parser_new_expression): Parse an ill-formed direct-new-declarator after a parenthesized type-id to emit good diagnostic. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3960&r2=1.3961 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.173&r2=1.174
Subject: Bug 14181 CVSROOT: /cvs/gcc Module name: gcc Changes by: giovannibajo@gcc.gnu.org 2004-02-19 03:09:59 Modified files: gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/parse: new2.C Log message: PR c++/14181 * g++.dg/parse/new2.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3516&r2=1.3517 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/new2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
Subject: Bug 14181 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: giovannibajo@gcc.gnu.org 2004-02-19 03:20:19 Modified files: gcc/cp : ChangeLog parser.c Log message: PR c++/14181 * parser.c (cp_parser_new_expression): Parse an ill-formed direct-new-declarator after a parenthesized type-id to emit good diagnostic. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.55&r2=1.3892.2.56 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.157.2.13&r2=1.157.2.14
Subject: Bug 14181 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: giovannibajo@gcc.gnu.org 2004-02-19 03:23:28 Modified files: gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/parse: new2.C Log message: PR c++/14181 * g++.dg/parse/new2.C: New test. PR c++/14181 * g++.dg/parse/new2.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.90&r2=1.3389.2.91 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/new2.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
Fixed in GCC 3.4.0 and 3.5.0. pr14181.cc:7: error: array bound forbidden after parenthesized type-id pr14181.cc:7: note: try removing the parentheses around the type-id Thank you for the report!
I forgot to say, I also added a note about this in http://gcc.gnu.org/gcc- 3.4/changes.html.