[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:17:58 PDT 2016


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

--- Comment #7 from Andrei Alexandrescu <andrei at erdani.com> ---
(In reply to Johan Engelen from comment #6)
> >  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;
> }

In this case I agree coverage should be as usual. The presence of "return"
changes things.

--


More information about the Digitalmars-d-bugs mailing list