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++ - DMC 8.45 and new/delete

↑ ↓ ← Wu Yongwei <Wu_member pathlink.com> writes:
Hi, Walter,

While I believe DMC has improved much in standard conformance, it is always weak
in new/delete.  I have not been to compile my memory leak detector
<URL:http://wyw.dcweb.cn/leakage.htm> under DMC because of this.  Specifically
it has the following problems:

1) Exception specification in operator new/delete results in an obscure message
like:

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 )

Even "throw()" cannot be used:

test.cpp(9) : Error: 'operator del' previously declared as something else
It was declared as: void C func(void *)
It is now declared: void C func(void *)

(And 'operator del' does not look better than 'operator delete'.)

2) Placement deallocation functions cannot be declared or defined:

test.cpp(9) : Error: must be void operator delete(void * [,size_t]);

3) `operator new' still defaults to the nothrow mode.  (Hey, old code should use
old compilers, or define their own global `operator new'.  Microsoft's `operator
new' does not throw in MSVC 6.0, but it does in MSVC 7.1.)

4) Use of new(nothrow) gives a strange error:

no_ptr = new(nothrow) Obj;
^
test.cpp(15) : Error: no match for function '?2(unsigned ,const std::nothrow_t)'

I really, really hope you can improve on this.

Best regards,

Yongwei
Sep 26 2005
→ "Walter Bright" <newshound digitalmars.com> writes:
All right, it's probably time to fix all that.
Sep 27 2005
→ Wu Yongwei <Wu_member pathlink.com> writes:
C:\TEMP>test

C:\TEMP>test 1
Object deleted
Exception

The "Object deleted" message shows a problem: `operator delete' should not be
called in this case.  It is an old problem too.  This can really harm normal
program that can throw in constructors.

Best regards,

Yongwei
Sep 27 2005