Thread overview
[Issue 18605] False unreachable warning generated when labeled continue is used
Mar 13, 2018
Yuxuan Shui
Mar 13, 2018
Yuxuan Shui
[Issue 18605] Missing return not detected when labeled continue is used
Mar 13, 2018
Yuxuan Shui
Dec 17, 2022
Iain Buclaw
May 09, 2023
RazvanN
March 13, 2018
https://issues.dlang.org/show_bug.cgi?id=18605

--- Comment #1 from Yuxuan Shui <yshuiv7@gmail.com> ---
This bug is worse than I thought:

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

void main() @safe {
    import std.stdio : writeln;
    writeln(test!(1,2,3)(1));
}

Results in an uninitialized return value in @safe code.

--
March 13, 2018
https://issues.dlang.org/show_bug.cgi?id=18605

--- Comment #2 from Yuxuan Shui <yshuiv7@gmail.com> ---
Reduced a bit more:

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

void main() @safe {
        import std.stdio : writeln;
        writeln(test!(1,2,3)());
}

--
March 13, 2018
https://issues.dlang.org/show_bug.cgi?id=18605

Yuxuan Shui <yshuiv7@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|False unreachable warning   |Missing return not detected
                   |generated when labeled      |when labeled continue is
                   |continue is used            |used

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=18605

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P4

--
May 09, 2023
https://issues.dlang.org/show_bug.cgi?id=18605

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |razvan.nitu1305@gmail.com
         Resolution|---                         |WORKSFORME

--- Comment #3 from RazvanN <razvan.nitu1305@gmail.com> ---
I cannot reproduce neither of the examples. I get:

test.d(1): Error: function `test.test!(1, 2, 3).test` no `return exp;` or
`assert(0);` at end of function
test.d(11): Error: template instance `test.test!(1, 2, 3)` error instantiating


So this seems to have been fixed.

--