c++/5805: the expression 'new (int*)[10]' should be a syntax error

Craig Rodrigues rodrigc@attbi.com
Tue Mar 5 05:50:00 GMT 2002


On Tue, Mar 05, 2002 at 10:29:57AM +0100, Moritz Franosch wrote:
> 
> rodrigc@gcc.gnu.org writes:
> 
> > Synopsis: the expression 'new (int*)[10]' should be a syntax error
> > 
> > State-Changed-From-To: open->closed
> > State-Changed-By: rodrigc
> > State-Changed-When: Sat Mar  2 18:49:58 2002
> > State-Changed-Why:
> >     With gcc 3.0.4, I get a compilation error:
> >     ++-new-bug.cpp: In function `int main()':
> >     g++-new-bug.cpp:6: cannot convert `int*' to `int**' in assignment

Your code is buggy.  This is the result of compiling
with the Comeau C++ compiler:

"11912.c", line 4: error: a value of type "int *" cannot be assigned to an
          entity of type "int **"
                 p=new (int*)[10];   // (2)
                  ^

"11912.c", line 5: error: a value of type "int *" cannot be assigned to an
          entity of type "int **"
                 p=(new (int*))[10]; // (3)
                  ^

"11912.c", line 2: warning: variable "p" was set but never used
                 int** p;


-- 
Craig Rodrigues        
http://www.gis.net/~craigr    
rodrigc@attbi.com



More information about the Gcc-bugs mailing list