This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/12115] New: arena new does not accept "struct" or "class" keywords.
- From: "thor at math dot tu-berlin dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 31 Aug 2003 12:49:50 -0000
- Subject: [Bug c++/12115] New: arena new does not accept "struct" or "class" keywords.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12115
Summary: arena new does not accept "struct" or "class" keywords.
Product: gcc
Version: 3.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: thor at math dot tu-berlin dot de
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i486-pc-linux-gnu
GCC host triplet: i486-pc-linux-gnu
GCC target triplet: i486-pc-linux-gnu
g++ does not accept code that allocates an object with an explicit struct/class
keyword thru area new. To reproduce this bug, enter the following program:
/* snip */
#include <stdlib.h>
class PrecinctKeeper {
public:
void *operator new(size_t size,int)
{
return malloc(size);
}
void operator delete(void *arg)
{
free(arg);
}
PrecinctKeeper(void)
{
}
};
class Band {
struct PrecinctKeeper *blocks;
//
public:
void Alloc()
{
blocks = new(5) class PrecinctKeeper;
}
};
int main(int argc,char **argv)
{
return 0;
}
/* snip */
and compile with g++-3.3 foo.cpp. The resulting error is:
band.cpp: In member function `void Band::Alloc()':
band.cpp:24: error: invalid use of undefined type `struct
Band::Alloc()::PrecinctKeeper'
band.cpp:24: error: forward declaration of `struct
Band::Alloc()::PrecinctKeeper'
band.cpp:24: error: ISO C++ forbids defining types within new
Workaround:
Replace
blocks = new(5) class PrecinctKeeper;
by
blocks = new(5) PrecinctKeeper;
i.e. drop the explicit "class" keyword.
This bug also appears in g++-2.95 and g++-3.2, maybe other releases are
affected as well.