www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Compiler crash!

reply Paul Guerra <Paul_member pathlink.com> writes:
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
parent =?UTF-8?B?VGhvbWFzIEvDvGhuZQ==?= writes:
-----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.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 -----BEGIN PGP SIGNATURE----- iD8DBQFC7/dm3w+/yD4P9tIRAqdbAJ9vfn5+EWc8MZzVOF+iKvXrujMbnQCbBW+7 9Pcznj2pzbs/6gKBEWRCN+E= =loDN -----END PGP SIGNATURE-----
Aug 02 2005