public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/18901] New: Type of 'new (T*) [n]'
@ 2004-12-09 10:02 wolfgang dot roehrl at de dot gi-de dot com
2004-12-09 12:59 ` [Bug c++/18901] " giovannibajo at libero dot it
2004-12-09 16:15 ` wolfgang dot roehrl at de dot gi-de dot com
0 siblings, 2 replies; 3+ messages in thread
From: wolfgang dot roehrl at de dot gi-de dot com @ 2004-12-09 10:02 UTC (permalink / raw)
To: gcc-bugs
Dear all,
I would like to post a fault report for the GNU C/C++ compiler 3.3-e500.
We use the compiler to generate code for a PowerPC processor.
Used invokation line for the GNU C++ compiler:
ccppc -c -x c++ -ansi -Wall -Werror -mcpu=8540 -fverbose-asm -mbig
-fmerge-templates -mmultiple -mno-string -mstrict-align -O3
-fno-exceptions -fno-rtti -fno-builtin-printf
-I<different include paths>
-D<differen #define's>
K.CPP -oK.O
// example program
void f1 (int*);
void f2 (int**);
void f3 ()
{
f1 (new (int*)[3]); // legal
f2 (new (int*)[3]); // illegal
}
I get the error message "cannot convert `int**' to `int*' for argument `1'
to `void f1(int*)'".
I think this is unjustified since the expression 'new (int*)[n]' should be
parsed as '(new (int*))[n]' and not as 'new int*[n]' as the GNU compiler
seems to do: according to the standard 5.3.4 the above '(int*)' in the new-
expression should be recognized as '( type-id )'.
Therefore the compiler should accept the call of f1() and refuse the call
of f2().
With kind regards
W. Roehrl
--
Summary: Type of 'new (T*) [n]'
Product: gcc
Version: 3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: wolfgang dot roehrl at de dot gi-de dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: sparc-sun-solaris2.5.1
GCC host triplet: i386-pc-mingw32
GCC target triplet: powerpc-wrs-vxworks
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18901
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/18901] Type of 'new (T*) [n]'
2004-12-09 10:02 [Bug c++/18901] New: Type of 'new (T*) [n]' wolfgang dot roehrl at de dot gi-de dot com
@ 2004-12-09 12:59 ` giovannibajo at libero dot it
2004-12-09 16:15 ` wolfgang dot roehrl at de dot gi-de dot com
1 sibling, 0 replies; 3+ messages in thread
From: giovannibajo at libero dot it @ 2004-12-09 12:59 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-12-09 12:59 -------
My understanding is that both the expressions are ill-formed, because you
cannot use the parentesis around the type-id in a new-array expression.
GCC 3.4 and above correctly rejects both lines. There is an entry about this in
http://gcc.gnu.org/gcc-3.4/changes.html.
Do you agree with this or am I missing something?
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |mmitchel at gcc dot gnu dot
| |org
Status|UNCONFIRMED |WAITING
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18901
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/18901] Type of 'new (T*) [n]'
2004-12-09 10:02 [Bug c++/18901] New: Type of 'new (T*) [n]' wolfgang dot roehrl at de dot gi-de dot com
2004-12-09 12:59 ` [Bug c++/18901] " giovannibajo at libero dot it
@ 2004-12-09 16:15 ` wolfgang dot roehrl at de dot gi-de dot com
1 sibling, 0 replies; 3+ messages in thread
From: wolfgang dot roehrl at de dot gi-de dot com @ 2004-12-09 16:15 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From wolfgang dot roehrl at de dot gi-de dot com 2004-12-09 16:15 -------
Subject: Antwort: Type of 'new (T*) [n]'
Hi all,
I am responding to the Comments From giovannibajo at libero dot it
2004-12-09 12:59 (Bug report 18901):
The expression 'new (int*)[3]' is NOT an array-new. It simply allocates a
int*, i.e. a pointer to an int. So new returns a pointer to a pointer to an
int, which in turn is is derefenced by [3] and we get a pointer to an int.
The latter operation is _semantically_ illegal because we didn't allocate
an array of pointers to ints.
But my point is that the _type_ of 'new (int*)[3]' is int* and function
f1() should be called.
And I think the code fragment woud be valid if we wrote 'new (int*)[0]'
instead of 'new (int*)[3]'.
W. Roehrl
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18901
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-12-09 16:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-09 10:02 [Bug c++/18901] New: Type of 'new (T*) [n]' wolfgang dot roehrl at de dot gi-de dot com
2004-12-09 12:59 ` [Bug c++/18901] " giovannibajo at libero dot it
2004-12-09 16:15 ` wolfgang dot roehrl at de dot gi-de dot com
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).