[comp.os.msdos.programmer] BC++ 2.0's great, but beware...

martin@hpopd.pwd.hp.com (Martin Wink) (03/28/91)

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.

cadsi@ccad.uiowa.edu (CADSI) (03/30/91)

From article <37390006@hpopd.pwd.hp.com>, by martin@hpopd.pwd.hp.com (Martin Wink):
> I really love the new Borland C++ 2.0 compiler, but...
> 
> I've got two bugs which I'd like to share with you.
> 

...
 
I have another one that is real wierd:
I use (for BC++) a 385/25 box with 2 Meg.  I load the environment with
bc/x.  Now I link the project (application) I'm working on immediately
and it links quite fast.  HOWEVER, If I do ANY compiles, the link
takes longer each time I relink.  This gets to the point that it takes
almost 20 minutes to link my app.  If I don't relink, quit bcc, reload
bcc and link, the link takes about 20 seconds.  Figure that????

|----------------------------------------------------------------------------|
|Tom Hite					|  The views expressed by me |
|Manager, Product development			|  are mine, not necessarily |
|CADSI (Computer Aided Design Software Inc.	|  the views of CADSI.       |
|----------------------------------------------------------------------------|