www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17688] New: ICE with static foreach directly inside switch

https://issues.dlang.org/show_bug.cgi?id=17688

          Issue ID: 17688
           Summary: ICE with static foreach directly inside switch
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: ice, ice-on-valid-code
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: timon.gehr gmx.ch

The following code generates an ICE:

---
void main(){
    final switch(1) static foreach(x;0..1){ case 1: return; }
}
---

---
Statement::blockExit(0x7fe21d91c360)
static foreach (x; 0 .. 1)
{
case 1:
{
return ;
}
}

core.exception.AssertError ddmd/blockexit.d(90): Assertion failure
----------------
---

The reason is that the DMD code base does not uphold some invariants I took for
granted.

--
Jul 25