This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/18901] Type of 'new (T*) [n]'
- From: "wolfgang dot roehrl at de dot gi-de dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Dec 2004 16:15:34 -0000
- Subject: [Bug c++/18901] Type of 'new (T*) [n]'
- References: <20041209100220.18901.wolfgang.roehrl@de.gi-de.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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