Bug 10524 – Switch skips initialization of 'with' variable

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-07-01T17:56:00Z
Last change time
2016-06-18T21:03:55Z
Keywords
accepts-invalid, pull, wrong-code
Assigned to
nobody
Creator
4denizzz
Depends on
14532
See also
https://issues.dlang.org/show_bug.cgi?id=14532

Comments

Comment #0 by 4denizzz — 2013-07-01T17:56:12Z
struct S { int field; } void main() { int a = 1; S struct_with_long_name; switch( a ) { case 0: struct_with_long_name.field = 444; // ok break; with( struct_with_long_name ) { case 1: field = 555; // segfault break; } default: break; } }
Comment #1 by yebblies — 2013-07-14T06:40:39Z
This appears to work with 2.064 alpha on win32. Can anybody reproduce?
Comment #2 by bearophile_hugs — 2013-07-14T07:12:04Z
(In reply to comment #1) > This appears to work with 2.064 alpha on win32. Can anybody reproduce? I can reproduce the segfault at the annotated line: struct S { int field; } void main() { int a = 1; S s; switch (a) with (s) { case 0: s.field = 444; // ok break; case 1: field = 555; // segfault break; default: break; } }
Comment #3 by yebblies — 2013-11-20T22:54:17Z
Ah, this is basically issue 602 with switch instead of goto.
Comment #4 by bugzilla — 2016-06-15T18:15:03Z
Comment #5 by bugzilla — 2016-06-18T21:03:55Z
*** This issue has been marked as a duplicate of issue 14532 ***