Bug 14181 - Cryptic error message for code that compiled without warnings in 3.3.x
Summary: Cryptic error message for code that compiled without warnings in 3.3.x
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: 3.4.0
Assignee: Giovanni Bajo
URL:
Keywords: diagnostic, patch
Depends on:
Blocks:
 
Reported: 2004-02-17 17:40 UTC by David Daney
Modified: 2004-10-30 21:11 UTC (History)
1 user (show)

See Also:
Host: *
Target: *
Build: *
Known to work:
Known to fail: 3.4.0 4.0.0
Last reconfirmed: 2004-02-17 17:43:55


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Daney 2004-02-17 17:40:13 UTC
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...
Comment 1 Giovanni Bajo 2004-02-17 17:43:54 UTC
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.
Comment 2 Giovanni Bajo 2004-02-18 18:06:22 UTC
Patch submitted:
http://gcc.gnu.org/ml/gcc-patches/2004-02/msg01610.html
Comment 3 GCC Commits 2004-02-19 03:06:14 UTC
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

Comment 4 GCC Commits 2004-02-19 03:10:02 UTC
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

Comment 5 GCC Commits 2004-02-19 03:20:22 UTC
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

Comment 6 GCC Commits 2004-02-19 03:23:31 UTC
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

Comment 7 Giovanni Bajo 2004-02-19 03:24:52 UTC
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!
Comment 8 Giovanni Bajo 2004-02-19 03:25:28 UTC
I forgot to say, I also added a note about this in http://gcc.gnu.org/gcc-
3.4/changes.html.