www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18607] New: using labelled continue in tuple foreach can

https://issues.dlang.org/show_bug.cgi?id=18607

          Issue ID: 18607
           Summary: using labelled continue in tuple foreach can break
                    pure
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: elpenguino+D gmail.com

int test(T...)() pure {
        L:foreach(_; T) {
                continue L;
                return 1;
        }
}

The only return statement in this function is unreachable, so this returns an
uninitialized int as long as >= 1 template parameter is specified. This should
not have been able to be marked pure.

The pure attribute is automatically inferred but I've explicitly added it here.

--
Mar 13 2018