pmoore@hemel.bull.co.uk (Paul Moore) (01/30/91)
I know that this was thrashed out in previous traffic but I thought I would
repost as I have just been bitten again, this time in a different construct
and again it took me a long time to sort it out (its probably due to my
programming style of declaring things near to where I need them).
.....
switch(n)
{
case a:
Class object;
case b:
......
}
If case b is done then Zortech 2.1 calls the destructor for object even though
it has not bee constructed.
The general concensus was that this is a programming bug that should be
fatalled by the compiler (cfront does fatal it) - it should certainly
issue a warning - Zortech silently accepts it. (I am sending a copy
of this to ztc-bugs)
jimad@microsoft.UUCP (Jim ADCOCK) (02/07/91)
In article <1991Jan30.124321.17051@hemel.bull.co.uk> pmoore@hemel.bull.co.uk (Paul Moore) writes: |switch(n) |{ | case a: | Class object; | case b: | ...... |} |The general concensus was that this is a programming bug that should be |fatalled by the compiler (cfront does fatal it) - it should certainly |issue a warning - Zortech silently accepts it. (I am sending a copy |of this to ztc-bugs) Illegal -- iff object has an initializer. But, legal switch statements would include: switch(n) { case 1: printf("case 1\n"); default: Class object; } or switch(n) { case 1: { Class object; } case 2: .... } I think it'll take awhile for compilers to get this all sorted out, and it's not yet defined what the constraints are that compilers have to diagnosed in this regard.