Issue 17688 - ICE with static foreach directly inside switch
Summary: ICE with static foreach directly inside switch
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: ice, ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2017-07-25 23:59 UTC by timon.gehr
Modified: 2017-08-16 13:24 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description timon.gehr 2017-07-25 23:59:11 UTC
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.
Comment 1 timon.gehr 2017-08-07 18:46:01 UTC
https://github.com/dlang/dmd/pull/7023
Comment 2 github-bugzilla 2017-08-08 22:07:23 UTC
Commits pushed to master at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/7ebda47f6a162ce3de774a042207eb883908b650
fix Issue 17688 - ICE with static foreach directly inside switch

https://github.com/dlang/dmd/commit/e1e68148e0cd0eb1cfa21a8c0b24afcf7f3781f9
Merge pull request #7023 from tgehr/fix17688

fix Issue 17688 - ICE with static foreach directly inside switch
merged-on-behalf-of: Walter Bright <WalterBright@users.noreply.github.com>
Comment 3 github-bugzilla 2017-08-16 13:24:11 UTC
Commits pushed to stable at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/7ebda47f6a162ce3de774a042207eb883908b650
fix Issue 17688 - ICE with static foreach directly inside switch

https://github.com/dlang/dmd/commit/e1e68148e0cd0eb1cfa21a8c0b24afcf7f3781f9
Merge pull request #7023 from tgehr/fix17688