Bug 17111 – DMD accepts switch statement with non-const case variables

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2017-01-20T20:29:00Z
Last change time
2017-03-22T12:21:23Z
Assigned to
nobody
Creator
yshuiv7

Comments

Comment #0 by yshuiv7 — 2017-01-20T20:29:29Z
Example: void main() { alias TestType = ulong; // won't compile if = ubyte import std.stdio; TestType a,b,c; readf("%s %s %s ", &a, &b, &c); switch(c){ case a: writeln("a");break; case b: writeln("b");break; default: assert(false); } } Forum thread: https://forum.dlang.org/post/[email protected]
Comment #1 by bitter.taste — 2017-01-20T21:51:47Z
Comment #2 by github-bugzilla — 2017-02-11T16:29:24Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/84fcc60ae769015e5a2acfbc73881e7808799e48 Fix issue 17111 - More robust detection of variables used as case exp. https://github.com/dlang/dmd/commit/e15fb01c75e09934c4a89098062df605d9e5427f Merge pull request #6477 from LemonBoy/b17111 Fix issue 17111 - More robust detection of variables used as case exp.
Comment #3 by github-bugzilla — 2017-02-24T20:34:23Z
Commits pushed to newCTFE at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/84fcc60ae769015e5a2acfbc73881e7808799e48 Fix issue 17111 - More robust detection of variables used as case exp. https://github.com/dlang/dmd/commit/e15fb01c75e09934c4a89098062df605d9e5427f Merge pull request #6477 from LemonBoy/b17111
Comment #4 by github-bugzilla — 2017-03-22T12:21:23Z
Commits pushed to stable at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/84fcc60ae769015e5a2acfbc73881e7808799e48 Fix issue 17111 - More robust detection of variables used as case exp. https://github.com/dlang/dmd/commit/e15fb01c75e09934c4a89098062df605d9e5427f Merge pull request #6477 from LemonBoy/b17111