July 29, 2005 Compiler crash! | ||||
---|---|---|---|---|
| ||||
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; } } |
August 02, 2005 Re: Compiler crash! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul Guerra Attachments: | 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.html > Label 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 |
Copyright © 1999-2021 by the D Language Foundation