Bug 11977 – Regression 2.065.b1: goto skips declaration of variable
Status
RESOLVED
Resolution
INVALID
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-01-23T05:17:00Z
Last change time
2014-01-23T06:05:17Z
Assigned to
nobody
Creator
doob
Comments
Comment #0 by doob — 2014-01-23T05:17:53Z
This code used to compile with DMD 2.064.2:
void main()
{
int i;
switch (i)
{
case 1:
goto Lno_consume; // Line 10
break;
default:
}
int x; // Line 15
for (int* tp = &x, tp_end = tp + 3; tp < tp_end; ++tp) { }
Lno_consume: {}
}
But fails to compile with 2.065.b1 wit this error message:
Error: goto skips declaration of variable main.main.x at main.d(15)
Comment #1 by yebblies — 2014-01-23T06:05:17Z
As you can see, the goto clearly skips the initialization of x.
Not a regression, the compiler is finally following the spec: "It is illegal for a GotoStatement to be used to skip initializations."