This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c++/9658: compiler accepts invalid code
- From: papadopo at sources dot redhat dot com, at at sources dot redhat dot com, shfj at sources dot redhat dot com, cea at sources dot redhat dot com, fr at sources dot redhat dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 11 Feb 2003 10:21:09 -0000
- Subject: c++/9658: compiler accepts invalid code
- Reply-to: papadopo at sources dot redhat dot com, at at sources dot redhat dot com, shfj at sources dot redhat dot com, cea at sources dot redhat dot com, fr at sources dot redhat dot com
>Number: 9658
>Category: c++
>Synopsis: compiler accepts invalid code
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: accepts-illegal
>Submitter-Id: net
>Arrival-Date: Tue Feb 11 10:26:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Dimitri Papadopoulos
>Release: gcc-3.2.2
>Organization:
>Environment:
Solaris 8 (7/01)
>Description:
Sun and SGI compilers emit an error on the attached code:
$ CC -V
CC: Sun WorkShop 6 update 2 C++ 5.3 Patch 111685-12 2002/12/16
$ CC -c foo.cc
"foo.cc", line 2: Error: Cannot use int* to initialize int**.
1 Error(s) detected.
$
$ CC -version
MIPSpro Compilers: Version 7.3.1.3m
$ CC -c foo.cc
cc-1140 CC: ERROR File = foo.cc, Line = 2
A value of type "int *" cannot be used to initialize an entity of type "int **"
.
int **foo = new (int*)[33];
^
...
$
The GNU compiler doesn't.
The Sun engineers insist this is not legal code.
>How-To-Repeat:
$ g++ -Wall -c foo.c
$
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="foo.cc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="foo.cc"
aW50IG1haW4oKSB7CiAgIGludCAqKmZvbyA9IG5ldyAoaW50KilbMzNdOwp9Cg==