www.digitalmars.com         C & C++   DMDScript  

c++ - Very old bug with redefining new/delete

Glad to see that there are many improvements. However, an old bug (since the
first time I used DMC, v8.29 or so) is still there, and is reproducible with
the following simple program:

#include <new>

void* operator new(unsigned size) throw(std::bad_alloc);

int main()
    return 0;

The following lines are in dm\include\new.h, but uncommenting them will
trigger similar errors (so really implicitly declared ones seem to have no
exception specifications):

// Implicitly declared ones
//void* operator new(unsigned size) throw(std::bad_alloc);
//void* operator new[](unsigned size) throw(std::bad_alloc);
//void operator delete(void* ptr) throw();
//void operator delete[](void* ptr) throw();

BTW, the error message is very confusing, since it does not show the exception

void* operator new(unsigned size) throw(std::bad_alloc);
test.cpp(4) : Error: 'operator new' previously declared as something else
It was declared as: void *C func(unsigned )
It is now declared: void *C func(unsigned )
--- errorlevel 1

Best regards,

Sep 23 2006