Thread overview | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
March 14, 2005 [DMD 0.118] 'switch ' crtical bug, | ||||
---|---|---|---|---|
| ||||
This program below ends abnormally with the message: C:\d\test>test.exe Error: Switch Default test(21) If you will add default: break; in the switch everything will be fine. Either compiler shall report "no default" either it shall not generate an error in runtime. Andrew. === test.d ================================================= import std.stdio; enum DRAW: uint // drawChars flags { LEFT = 0x0, CENTER = 0x1, RIGHT = 0x2, TOP = 0x00, MIDDLE = 0x10, BOTTOM = 0x20, END_ELLIPSIS = 0x100, PATH_ELLIPSIS = 0x200, WORD_ELLIPSIS = 0x300, } int main(char[][] args) { uint f = 0x10; switch( f & 0xF00 ) { case DRAW.END_ELLIPSIS: writef("END_ELLIPSIS\n"); break; case DRAW.PATH_ELLIPSIS: writef("PATH_ELLIPSIS\n"); break; case DRAW.WORD_ELLIPSIS: writef("WORD_ELLIPSIS\n"); break; } return 0; } |
March 14, 2005 Re: [DMD 0.118] 'switch ' crtical bug, | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrew Fedoniouk | Andrew Fedoniouk wrote: > This program below ends abnormally with the message: > C:\d\test>test.exe > Error: Switch Default test(21) It disappears in -release mode, though... > If you will add > default: break; > in the switch everything will be fine. Yes, and even the (-w) warning goes away. > Either compiler shall report "no default" either it shall not generate an error in runtime. This is a known behaviour, though (not a bug). See also: http://www.prowiki.org/wiki4d/wiki.cgi?ShortFrequentAnswers --anders |
March 15, 2005 Re: [DMD 0.118] 'switch ' crtical bug, | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anders F Björklund | Thanks Anders. I guess we should add there "no return value" issue also. Like: Rect place(Rect r) { _place = r; } will also generate an exception in debug but will compile fine. Andrew. "Anders F Björklund" <afb@algonet.se> wrote in message news:d154md$2md5$3@digitaldaemon.com... > Andrew Fedoniouk wrote: > >> This program below ends abnormally with the message: >> C:\d\test>test.exe >> Error: Switch Default test(21) > > It disappears in -release mode, though... > >> If you will add >> default: break; >> in the switch everything will be fine. > > Yes, and even the (-w) warning goes away. > >> Either compiler shall report "no default" either it shall not generate an error in runtime. > > This is a known behaviour, though (not a bug). See also: > > http://www.prowiki.org/wiki4d/wiki.cgi?ShortFrequentAnswers > > --anders |
March 15, 2005 Re: [DMD 0.118] 'switch ' crtical bug, | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrew Fedoniouk | "Andrew Fedoniouk" <news@terrainformatica.com> wrote in message news:d1549k$2o21$1@digitaldaemon.com... > This program below ends abnormally with the message: > C:\d\test>test.exe > Error: Switch Default test(21) Yes, that's expected behavior in D. Unlike C, there is no implied default: break; inserted in a switch statement without an explicit break. D will insert an implicit default: throw new SwitchError(); |
March 15, 2005 Re: [DMD 0.118] 'switch ' crtical bug, | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | >
> Yes, that's expected behavior in D. Unlike C, there is no implied
> default: break;
> inserted in a switch statement without an explicit break. D will insert an
> implicit
> default: throw new SwitchError();
>
Thanks, Walter.
My assumption was that command line:
dmd.exe test.d
will produce release version. That was wrong (why, btw?).
It produces debug version and so I am getting
new SwitchError();
And only if I explicitly say "-release" then it disappears.
Andrew.
|
March 15, 2005 Re: [DMD 0.118] 'switch ' crtical bug, | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrew Fedoniouk | On Mon, 14 Mar 2005 19:03:46 -0800, Andrew Fedoniouk wrote: [snip] > > My assumption was that command line: > > dmd.exe test.d > > will produce release version. That was wrong (why, btw?). My guess is that nearly all compiles are done to create an edition of the application that is about to undergo testing, as opposed to an edition that is destined for an end-user. (Except, of course, if you're MS :D ) So, one would only use the -release option to create the edition that will be used for User Acceptance Testing or similar, and that will be used to create shippable copies of the application. -- Derek Parnell Melbourne, Australia http://www.dsource.org/projects/build/ http://www.prowiki.org/wiki4d/wiki.cgi?FrontPage 15/03/2005 2:33:08 PM |
March 15, 2005 Re: [DMD 0.118] 'switch ' crtical bug, | ||||
---|---|---|---|---|
| ||||
Posted in reply to Derek Parnell | "Derek Parnell" <derek@psych.ward> wrote in message news:1gfotxu9j0id.g73pfkq3o5f2.dlg@40tude.net... > My guess is that nearly all compiles are done to create an edition of the application that is about to undergo testing, as opposed to an edition that > is destined for an end-user. (Except, of course, if you're MS :D ) > > So, one would only use the -release option to create the edition that will be used for User Acceptance Testing or similar, and that will be used to create shippable copies of the application. Yes. |
March 15, 2005 Re: [DMD 0.118] 'switch ' crtical bug, | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | "Walter" <newshound@digitalmars.com> wrote in message news:d15ljm$5s6$1@digitaldaemon.com... > > "Derek Parnell" <derek@psych.ward> wrote in message news:1gfotxu9j0id.g73pfkq3o5f2.dlg@40tude.net... >> My guess is that nearly all compiles are done to create an edition of the application that is about to undergo testing, as opposed to an edition > that >> is destined for an end-user. (Except, of course, if you're MS :D ) >> >> So, one would only use the -release option to create the edition that >> will >> be used for User Acceptance Testing or similar, and that will be used to >> create shippable copies of the application. > > Yes. > Sure :) I guess that definition of compiler option should state: -debug compile in debug code (default option) (default option) - is my addon.... If you don't mind to catch someone else on this.... |
March 15, 2005 Re: [DMD 0.118] 'switch ' crtical bug, | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrew Fedoniouk | Andrew Fedoniouk wrote:
> Sure :) I guess that definition of compiler option should state:
>
> -debug
> compile in debug code (default option)
>
> (default option) - is my addon....
>
> If you don't mind to catch someone else on this....
The thing is that -debug and -release are *unrelated* options.
-debug activates a "version" (i.e. the debug { } code areas),
while -release removes contracts and switch/bounds checking
Then there are also the -g and -O flags too, which are also
semi-related but totally different. And of course -inline...
And yes, it's a little confusing (at least at first)
--anders
|
Copyright © 1999-2021 by the D Language Foundation