digitalmars.D.bugs - Compiler crash!
- Paul Guerra (15/15) Jul 28 2005 The following piece of code crashes the compiler (at least on Win32).
- =?UTF-8?B?VGhvbWFzIEvDvGhuZQ==?= (20/43) Aug 02 2005 -----BEGIN PGP SIGNED MESSAGE-----
The following piece of code crashes the compiler (at least on Win32). int main() { int u=2; switch(u) { case 1: void j() { case 2: u++; } break; } }
Jul 28 2005
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Paul Guerra schrieb:The following piece of code crashes the compiler (at least on Win32). int main() { int u=2; switch(u) { case 1: void j() { case 2: u++; } break; } }Added to DStress as http://dstress.kuehne.cn/run/c/case_01.d Reason: http://www.digitalmars.com/d/statement.htmlLabel name spaces do not nest, i.e. a label inside a block statement is accessible from outside that block.Case statements and default statements associated with the switch can be nested within block statements; they do not have to be in the outermost block.A block statement is a sequence of statements enclosed by { }.Functions are block statements, thus the code is legal. Either I'm misreading the documentation or the documentation should be changed to render this code illegal. Suggestion: LabeledStatements and CaseStatements declared inside of functions that are nested in the current scope can't be accessed via BreakStatements, GotoStatements and SwitchStatements. Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFC7/dm3w+/yD4P9tIRAqdbAJ9vfn5+EWc8MZzVOF+iKvXrujMbnQCbBW+7 9Pcznj2pzbs/6gKBEWRCN+E= =loDN -----END PGP SIGNATURE-----
Aug 02 2005