Super Lint

xs0 xs0 at xs0.com
Wed Sep 20 14:20:16 PDT 2006


Walter Bright wrote:
> I've been interested in various ideas for static checking for common bug 
> patterns for D. For example:
> 
>     for (int i = 0; i < 10; i++)
>     {    foo();
>         break;
>     }
> 
> would be flagged as a suspicious use of break. Are there any legitimate 
> uses of break in this manner? Any thoughts and ideas in this direction?

Well, I occasionally write something similar:

for (int i = 0; i < max_retries; i++) {
     try {
         foo();
     } catch (Exception e) {
         continue;
     }
     break;
}

I'm not sure if it's related, though (does the continue make Lint shut 
up?). I have no "legitimate" ideas about breaking unconditionally, 
though, except for debugging.


xs0



More information about the Digitalmars-d mailing list