Super Lint

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Wed Sep 20 15:04:25 PDT 2006


Walter Bright wrote:
> xs0 wrote:
>> 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;
>> }
> 
> Hmm. That does look like a quite reasonable use case.

It also looks like a quite /detectable/ use case. Just look for a 
continue statement somewhere in that loop (and outside any nested ones).



More information about the Digitalmars-d mailing list