www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7894] New: [CTFE] - goto within ForStatement restarts loop

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

           Summary: [CTFE] - goto within ForStatement restarts loop
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: dawg dawgfoto.de



cat > bug.d << CODE
int foo()
{
    foreach(v; 0 .. 2)
    {
        auto n = v;
    Lagain:
        if (n--) goto Lagain;
    }
    return 0;
}

enum ctfe = foo();
CODE

dmd -c bug.d

--------

This will loop endlessly because the loop initializer is
reinterpreted after each goto.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 12 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7894


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au



Slightly reduced test case:

int bug7894()
{
    for (int k = 0; k < 2; ++k) {
        goto Lagain;
Lagain: ;
    }
    return 1;
}
static assert( bug7894() );

Actually the loop initializer isn't reinterpreted after each goto. What's
happening is that the increment is skipped.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 09 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7894




Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/9d6bc4560c3554b866f4bc8c6ace50b56c091953
Fix issue 7894 [CTFE] - goto within ForStatement restarts loop

Also fixes a very similar bug in do-while loops

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 14 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7894


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 14 2012