digitalmars.D.bugs - [Issue 1605] New: break in switch with goto breaks in ctfe
- d-bugmail puremagic.com (40/40) Oct 21 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1605
- d-bugmail puremagic.com (39/39) Aug 24 2009 http://d.puremagic.com/issues/show_bug.cgi?id=1605
- d-bugmail puremagic.com (12/12) Sep 03 2009 http://d.puremagic.com/issues/show_bug.cgi?id=1605
http://d.puremagic.com/issues/show_bug.cgi?id=1605 Summary: break in switch with goto breaks in ctfe Product: D Version: 1.022 Platform: PC OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: lutger.blijdestijn gmail.com I stumbled upon a case where a break statement in a switch causes the outer while loop to exit. This happens only when the function is evaluated at compile time and a goto statement is involved. Forgive me the bad example: int Break() { int i = 0; while (true) { switch(i) { case 0: goto LABEL; // comment out this line and all is fine LABEL: // at compile time, this breaks out of the while loop: break; default: return i; } i = 1; } return 0; // unreachable } void main() { assert (Break() == 1); // ok static assert(Break() == 1); // not ok } --
Oct 21 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1605 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch CC| |clugdbug yahoo.com.au --- Comment #1 from Don <clugdbug yahoo.com.au> 2009-08-24 04:21:21 PDT --- Actually this has nothing to do with switch or break. It only requires 'goto' inside a while loop. Reduced test case: int Break() { int i = 0; while (true) { goto LABEL; LABEL: if (i!=0) return i; i = 27; } assert(i==27); // this passes, it did actually execute the loop. return 88; // unreachable } static assert(Break() == 27); ----------- It's failing because the test for continuing to execute is wrong. ---- PATCH: interpret.c, Expression *WhileStatement::interpret(InterState *istate) if (e == EXP_BREAK_INTERPRET) return NULL; - if (e != EXP_CONTINUE_INTERPRET) + if (e && e != EXP_CONTINUE_INTERPRET) return e; } while (1) { e = condition->interpret(istate); -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 24 2009
http://d.puremagic.com/issues/show_bug.cgi?id=1605 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla digitalmars.com Resolution| |FIXED --- Comment #2 from Walter Bright <bugzilla digitalmars.com> 2009-09-03 13:22:55 PDT --- Fixed dmd 1.047 and 2.032 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 03 2009