Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!spool.mu.edu!uwm.edu!bionet!agate!ucbvax!hplabs!otter.hpl.hp.com!hpopd!martin From: martin@hpopd.pwd.hp.com (Martin Wink) Newsgroups: comp.os.msdos.programmer Subject: BC++ 2.0's great, but beware... Message-ID: <37390006@hpopd.pwd.hp.com> Date: 28 Mar 91 13:23:28 GMT Organization: Hewlett-Packard CCG-PWD, UK. Lines: 49 I really love the new Borland C++ 2.0 compiler, but... I've got two bugs which I'd like to share with you. The first is that BCC does not report the illegal use of goto labels within block scopes containing destructors. This manifests itself when I have functions which return objects. Temporary objects are allocated within the current block scope to hold the return values. If on checking the return values I detect an error and do a goto, jumping over some of the function calls, I still have the destructors for the temporary objects called. The Programmer's Guide says it's illegal to do this, but the compiler itself doesn't. eg { stuff... if (check_error()) goto error_cleanup; value = fn_returning_obj(); value = fn_returning_obj(); value = fn_returning_obj(); error_cleanup: do_stuff... } The second problem is that I have found that when a destructor needs to call other destructors upon returning, they are called twice unless an explicit return statement is added. ClassA::~ClassA() { auto ClassB var; stuff... // if no return, ClassB::~ClassB() called twice. } I hope that this warning saves someone else the bother that I have gone through. cheers............. martin wink..... Advanced Image Management Systems Hewlett-Packard, Pinewood, UK.