public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/9658: compiler accepts invalid code
@ 2003-02-11 10:26 papadopo, at, shfj, cea, fr
  0 siblings, 0 replies; 2+ messages in thread
From: papadopo, at, shfj, cea, fr @ 2003-02-11 10:26 UTC (permalink / raw)
  To: gcc-gnats


>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==


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: c++/9658: compiler accepts invalid code
@ 2003-02-14 20:58 bangerth
  0 siblings, 0 replies; 2+ messages in thread
From: bangerth @ 2003-02-14 20:58 UTC (permalink / raw)
  To: at, gcc-bugs, gcc-prs, nobody, papadopo

Synopsis: compiler accepts invalid code

State-Changed-From-To: open->closed
State-Changed-By: bangerth
State-Changed-When: Fri Feb 14 20:58:12 2003
State-Changed-Why:
    That's a gcc extension. If you use -ansi -pedantic, you'll get
    tmp/g> /home/bangerth/bin/gcc-3.2.2-pre/bin/c++ -ansi -pedantic -c x.cc
    x.cc: In function `int main()':
    x.cc:2: warning: ISO C++ forbids array dimensions with parenthesized type in
       new
    
    The new parser in 3.4 rejects it outright (i.e. the extension
    has been removed):
    tmp/g> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc
    x.cc: In function `int main()':
    x.cc:2: error: expected `,' or `;'
    
    
    Wolfgang

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9658


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-02-14 20:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-11 10:26 c++/9658: compiler accepts invalid code papadopo, at, shfj, cea, fr
2003-02-14 20:58 bangerth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).