www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.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
specifications:

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,

Yongwei
Sep 23 2006