[Issue 16224] -cov marks the last line of do/while(0); as uncovered

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Jul 1 11:13:17 PDT 2016


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

--- Comment #6 from Johan Engelen <jbc.engelen at gmail.com> ---
>  The coverage analyzer marks the line with "while (0);" as uncovered, although that is an useless tidbit.

I don't think it is useless. In the OP example, while(0) is uncovered because
there is never a "fallthrough exit" of that scope. Consider something like this
where coverage of while(0) is useful. 

int fun(int x)
{
    do
    {
        if (x != 0)
            break;
        if (x != 1)
            break;
        if (x != -1)
            break;
        mightThrow(x);
    }
    while (0);
    return x * x * x;
}

--


More information about the Digitalmars-d-bugs mailing list