Community
Participate
Working Groups
The CDT parser hangs on certain code involving for statements. A sample piece of code which causes a hang is provided below. I have reproduced the hang with the sample code on Eclipse 2.1.1 with CDT 1.2, and Eclipse 3.0M5 with CDT 2.0. From my reading of the source code, the CDT parser handles the init segment of a for statement by first treating it as a declaration, and if this fails, as an expression. With the sample code, the init statement is not a declaration. However, the CDT parser appears to process it without error, as a declaration. If the code in question were "for (a = 1, b = 2;;);", the CDT parser appears to treat "a = 1, b = 2" not as an expression but as a declaration of two variables of type "a". The first variable has no name and is assigned to 1, and the second variable has the name "b" and is assigned to 2. I don't know that this behavior causes the sample code below to hang the parser, but it seems likely. Sample code: int foo() { int one; int two; for (one = 1, two = 2; 0;;); { int three; for (three = 3, two = 4; 0;;); for (two = 5; 0;;); return two + two; } }
This is a serious bug, as it has demonstrated a flaw in our simplification of the SimpleDeclaration portion of the grammar. I'm going to take some time to think about how to fix this one.
*** This bug has been marked as a duplicate of 55163 ***