This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Parse error in expression new (int*)[10]
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: "James KANZE" <jkanze at caicheuvreux dot com>
- Cc: gcc-bugs at gcc dot gnu dot org
- Date: 31 Jan 2003 21:53:07 +0100
- Subject: Re: Parse error in expression new (int*)[10]
- Organization: Integrable Solutions
- References: <OFF272CB86.BA262E68-ONC1256CBF.0047221E@caicheuvreux.com>
"James KANZE" <jkanze@caicheuvreux.com> writes:
| The following (illegal) program compiles with g++ 3.1:
I see below that you didn't use -pedantic to compile the program.
As a rule, when it comes to decide which invalid programs GCC
erroneously accepts, one ought to argue on the behaviour with
-pedantic. That is the fact; until it is accepted that GCC's default
behaviour should be conformant.
The above comment is not to say that who saw is a feature or not. It
is recalls ways too proceeed.
| -----------------------------------------
| #include <iostream>
| #include <typeinfo>
|
| void
| f()
| {
| int** ppi = new (int*)[ 10 ] ;
| }
|
| int
| main()
| {
| std::cout << typeid( new (int*)[10] ).name() << '\n' ;
| return 0 ;
| }
| -----------------------------------------
|
| There should be a type error on the line in the function f. The output
| from the typeid in main indicates that g++ is somehow interpreting this
| as if the parentheses weren't there in the new expression.
How could that be the case? "PPi" indicates "int**", and GCC
interprets the parentheses as indicating priority: Surely, it
certainly does -not- behave as if the parenthesis weren't there. I
believe the main issue is what it believes they indicate.
-- Gaby