Yet another slap on the hand by implicit bool to int conversions

Steven Schveighoffer schveiguy at yahoo.com
Mon Jun 20 08:15:49 PDT 2011


On Mon, 20 Jun 2011 11:10:58 -0400, bearophile <bearophileHUGS at lycos.com>  
wrote:

> Steven Schveighoffer:
>
>> In order to have a fix for something like this, you need the error to be
>> near 100% invalid.  Like nobody ever writes this as *valid* code:
>>
>> if(cond);
>>
>> no matter what cond is.
>
> My enhancement request was about redundancies in the code, that  
> sometimes hide implicit errors, they can't be 'near 100% invalid'. In  
> this case I am not looking for explicit errors, some/many of the  
> redundancies aren't bugs.

What I'm saying is, if the compiler errors out when a good percentage of  
the cases are valid, it will become a nuisance error, and continually  
ignored/worked around.  We do not want nuisance errors.  Even if you make  
it a error only with -w, I think people will just stop using -w.  It needs  
to be:

a) almost always an error when it is encountered
b) very easily worked around, but with code that isn't common.

I think with the extra parentheses idea, b is satisfied, but a is not.  I  
can't say that there isn't a case where a is not satisfied by some  
specific criteria, but I haven't seen it yet.

-Steve


More information about the Digitalmars-d mailing list