digitalmars.D.bugs - [Issue 24534] New: Having a label on a declaration makes it possible
- d-bugmail puremagic.com (38/38) May 03 https://issues.dlang.org/show_bug.cgi?id=24534
https://issues.dlang.org/show_bug.cgi?id=24534 Issue ID: 24534 Summary: Having a label on a declaration makes it possible to skip it with goto Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: issues.dlang jmdavisProg.com This code compiles and runs: --- void main() { int x; goto Label; Dummy: int y; Label: int z; import std.stdio; writeln(y); } --- The value of y is then garbage (e.g. 539662115), because the declaration for y was skipped, and it wasn't actually initialized. On the other hand, if the Dummy label is removed, then we get an error such as --- q.d(4): Error: `goto` skips declaration of variable `q.main.y` q.d(5): declared here --- So, it would appear that the label on the variable is confusing the compiler and causing it to not understand that a declaration has been skipped. --
May 03