Bug 17752 – Switch skips over declaration issued for explicitly uninitialized variables

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-08-13T16:50:57Z
Last change time
2018-02-09T15:17:57Z
Keywords
pull
Assigned to
No Owner
Creator
Mathias Lang
See also
https://issues.dlang.org/show_bug.cgi?id=16578

Comments

Comment #0 by mathias.lang — 2017-08-13T16:50:57Z
Currently the "switch skips over declaration of variable blahblah" deprecation message is issued even if the initialization is not done on purpose. For example the following code should compile without deprecation: ``` void main (string[] args) { switch (args.length) { int x = void; default: break; } } ``` On a related note, the warning should say "initialization" instead of declaration, as the stack address for the variable still exists.
Comment #1 by greensunny12 — 2018-02-05T14:47:50Z
Comment #2 by github-bugzilla — 2018-02-09T15:17:55Z
Commit pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/1af17a72b8629b087418c3dc909fd17f40e0a51c Fix Issue 17752 - Switch skips over declaration issued for explicitly uninitialized variables (#7842)