Bug 16523 – [ICE] Internal error: backend/symbol.c 1031

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2016-09-21T21:52:00Z
Last change time
2017-01-07T03:02:15Z
Keywords
ice-on-invalid-code
Assigned to
nobody
Creator
b2.temp

Comments

Comment #0 by b2.temp — 2016-09-21T21:52:32Z
void main() { int i; switch(i) { foreach(j; 0..10) case j:{} default: break; } } DMD: Internal error: backend/symbol.c 1031
Comment #1 by b2.temp — 2016-09-21T22:08:11Z
The culprit is the local variable, as shown by this reduction void main() { int i; switch(i) { int j; case j:{} default: break; } } which produces the same error.
Comment #2 by uplink.coder — 2016-09-21T22:20:20Z
It seems only to happen when the type is int. if you change the type of j to uint it does produce the correct error in frontend
Comment #3 by uplink.coder — 2016-09-21T22:33:08Z
dmds source suggests that variables are allowed in switch-statements, and that codegen should just generate an if-else-chain in this case. I think allowing non-static cases is going to be a bugfest, down the road and we should think hard about this behavior.
Comment #4 by uplink.coder — 2016-09-21T23:04:06Z
I found the reason why this is not caught. Should be fixed by https://github.com/dlang/dmd/pull/6146
Comment #5 by code — 2016-09-21T23:08:17Z
Not quite resolved yet until the PR is in. ;)
Comment #6 by mk — 2016-09-21T23:22:44Z
(In reply to uplink.coder from comment #3) > > I think allowing non-static cases is going to be a bugfest, down the road > and we should think hard about this behavior. Declaration of a non-const variable in a switch body is now deprecated in master.
Comment #7 by uplink.coder — 2016-09-22T00:02:34Z
(In reply to Martin Krejcirik from comment #6) > (In reply to uplink.coder from comment #3) > > > > I think allowing non-static cases is going to be a bugfest, down the road > > and we should think hard about this behavior. > > Declaration of a non-const variable in a switch body is now deprecated in > master. That is not the issue. The issue is weather they are compile-time or run-time values. I believe having run-time values in there is not the best of choices.
Comment #8 by github-bugzilla — 2016-10-07T08:50:56Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/cdeca315729264ddbdd72ad9a83ea4fc5762e0dd fix Issue 16523 - case variables should be const/immutable - use deprecation instead of warning - add fail_compilation test https://github.com/dlang/dmd/commit/8bcd0c1d65af9fd5c0afa7ee0ed7862b286eef1e Merge pull request #6146 from UplinkCoder/fix_16523 [Partial] Fix Issue 16523
Comment #9 by mk — 2016-10-07T09:47:26Z
*** Issue 7392 has been marked as a duplicate of this issue. ***
Comment #10 by github-bugzilla — 2016-11-04T09:05:23Z
Commits pushed to newCTFE at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/cdeca315729264ddbdd72ad9a83ea4fc5762e0dd fix Issue 16523 - case variables should be const/immutable https://github.com/dlang/dmd/commit/8bcd0c1d65af9fd5c0afa7ee0ed7862b286eef1e Merge pull request #6146 from UplinkCoder/fix_16523
Comment #11 by github-bugzilla — 2017-01-07T03:02:15Z
Commits pushed to stable at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/cdeca315729264ddbdd72ad9a83ea4fc5762e0dd fix Issue 16523 - case variables should be const/immutable https://github.com/dlang/dmd/commit/8bcd0c1d65af9fd5c0afa7ee0ed7862b286eef1e Merge pull request #6146 from UplinkCoder/fix_16523