[comp.lang.c++] AT&T 1.2.1 bug

jsimellon@cpsc.ucalgary.ca (Larry Mellon) (05/05/89)

Cfront 1.2.1 does not handle the declaration of data_types within
switch statements correctly, if the data_type has a destructor.

Example:
/**** start code fragment ***/
    case 0:
    {
        sim_event       ev;  // line N

	// code
        break;
    }
    case 1:
/*** end code fragment */

This produces the warning message from cc:
    "ex.c", line N: warning: statement not reached

What happens is cfront inserts a dtor call for 'ev' before the 'break'
statement to ensure the dtor is called before leaving the block.
Another dtor call seems to be inserted by default at the end of the
block, *after* the unconditional 'break' statement.

"So don't open blocks inside of switch statements." you say.  Please
see previous posting re: cfront bug requiring you to open blocks inside
of switch statements.

It's only a warning; I could live with it.  But when we ship our software
out, I'm not looking forward to explaining this to every user...

We're looking at porting our software to other versions of C++.  Can
anyone please tell me if your flavour of C++ handles switch statements
better, or if cfront 2.0 fixes this?

Larry Mellon <jsimellon@cpsc.ucalgary.ca>
Jade Simulations International (403) 282-5711