www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11977] New: Regression 2.065.b1: goto skips declaration of variable

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11977

           Summary: Regression 2.065.b1: goto skips declaration of
                    variable
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: doob me.com


--- Comment #0 from Jacob Carlborg <doob me.com> 2014-01-23 05:17:53 PST ---
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)

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 23 2014
parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11977


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies gmail.com
         Resolution|                            |INVALID


--- Comment #1 from yebblies <yebblies gmail.com> 2014-01-24 01:05:17 EST ---
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."

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 23 2014