www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - switch statement under debug - (0.88) windows

reply Russell <Russell_member pathlink.com> writes:
If you define a switch statement and don't have a default it exe will compile ok
for debug and release.  The release version runs ok but the debug version throws
an error saying 'switch with no default' which is not what I would expect.  Also
if you do this in a static lib it causes a windows violation and crashes the
program.

I don't believe switch without a default is/should be an error and the behaviour
between debug and release should be consistant, maybe a warning during compile?

Russell
May 10 2004
next sibling parent J Anderson <REMOVEanderson badmama.com.au> writes:
Russell wrote:

If you define a switch statement and don't have a default it exe will compile ok
for debug and release.  The release version runs ok but the debug version throws
an error saying 'switch with no default' which is not what I would expect.  

a debug statement. This run-time check is useful for finding cases where you forgot to check for a particular case.
Also
if you do this in a static lib it causes a windows violation and crashes the
program.
  

exception are you?
I don't believe switch without a default is/should be an error and the behaviour
between debug and release should be consistant
  

runtime performace / file size / memory usage. Therefore it would be a bad idea to have this debug test in release mode.
maybe a warning during compile?

Walters anti-warning. There are no warnings in D.
Russell

-Anderson: http://badmama.com.au/~anderson/
May 10 2004
prev sibling parent J C Calvarese <jcc7 cox.net> writes:
Russell wrote:
 If you define a switch statement and don't have a default it exe will compile
ok
 for debug and release.  The release version runs ok but the debug version
throws
 an error saying 'switch with no default' which is not what I would expect. 
Also
 if you do this in a static lib it causes a windows violation and crashes the
 program.
 
 I don't believe switch without a default is/should be an error and the
behaviour
 between debug and release should be consistant, maybe a warning during compile?
 
 Russell

Unfortunately, this is as Walter intends. I'd prefer a compile-time error on a missing default to the current mess, but I haven't written the compiler. Since I'm used to BASIC, I don't like the fallthrough nature of switch either. But the occasional runtime error for an unspecified case drives me crazy! -- Justin (a/k/a jcc7) http://jcc_7.tripod.com/d/
May 10 2004