This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Parse error in expression new (int*)[10]


"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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]