digitalmars.D.bugs - Bug with labeled breaks
- BCS (13/13) Aug 11 2005 The following code compiles as-is without complaint on 0.129(win) but wh...
- =?UTF-8?B?VGhvbWFzIEvDvGhuZQ==?= (44/60) Aug 13 2005 -----BEGIN PGP SIGNED MESSAGE-----
The following code compiles as-is without complaint on 0.129(win) but when it’s run it gets stuck in the second loop (line 6). There must be a bug in here somewhere. Either the "break foo" should exit the labeled block statement (hmm… that’s a thought) or it shouldn’t compile. Ether way the second loop should be unreachable. void main() { foo: { while(true)break foo; while(true){} //line 6 } }
Aug 11 2005
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 BCS schrieb:The following code compiles as-is without complaint on 0.129(win) but when it’s run it gets stuck in the second loop (line 6). There must be a bug in here somewhere. Either the "break foo" should exit the labeled block statement (hmm… that’s a thought) or it shouldn’t compile. Ether way the second loop should be unreachable. void main() { foo: { while(true)break foo; while(true){} //line 6 } }http://digitalmars.com/d/statement.html ==A== foo:{ while(true){ break foo; } while(true){ assert(0); } } ==B== { foo: while(true){ break foo; } while(true){ assert(0); } } It seems like the compiler is moving the label. in A: labeled BlockStatement in B: labeled WithStatement The code in A is illegal as "foo" doesn't mark "an enclosing while, for, do or switch statement". Added to DStress as http://dstress.kuehne.cn/nocompile/b/break_11_A.d http://dstress.kuehne.cn/nocompile/b/break_11_B.d http://dstress.kuehne.cn/nocompile/b/break_11_C.d http://dstress.kuehne.cn/nocompile/b/break_11_D.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFC/mg+3w+/yD4P9tIRAidPAJ4gCVXvYpIkSOrCjzW6M0hX7cMiEgCfciuV Byuy1EKTbIyzVPhDnWvAbmo= =8OLc -----END PGP SIGNATURE-----
Aug 13 2005