Possible new[] regression in 3.4 WRT 3.3.[12]

David Daney ddaney@avtrex.com
Mon Feb 16 21:34:00 GMT 2004


I have the following code that compiles without warnings with g++ 3.3.2 
(x86-pc-linux) and 3.3.1 (mipsel-linux).  But I get an error under 3.4.

Not being a C++ expert, can someone tell me if my code is bogus, or if 
this is a problem with 3.4.

Here is the code:

----------d1.cpp--------8<------------------------
char **
f1()
{
    char** pSections;
   
    // allocate an array of 10 char pointers.
    pSections = new (char*)[10];
   
    return pSections;
   
}
---------------8<----------------------------

These are the errors:

[daney@dl junk]$ mipsel-linux-g++ --version
mipsel-linux-g++ (GCC) 3.4.0 20040214 (prerelease)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
[daney@dl junk]$ mipsel-linux-g++ -c d1.cpp
d1.cpp: In function `char** f1()':
d1.cpp:7: error: expected `;' before '[' token

Thanks,
David Daney



More information about the Gcc mailing list