[C/C++ PATCH] Implement -Wtautological-compare (PR c++/66555, c/54979)
Richard Earnshaw
Richard.Earnshaw@foss.arm.com
Wed Jul 29 10:24:00 GMT 2015
On 22/07/15 19:43, Martin Sebor wrote:
> On 07/14/2015 09:18 AM, Marek Polacek wrote:
>> Code such as "if (i == i)" is hardly ever desirable, so we should be able
>> to warn about this to prevent dumb mistakes.
>
> I haven't tried the patch or even studied it very carefully but
> I wonder if this is also the case when i is declared volatile.
> I.e., do we want to issue a warning there? (If we do, the text
> of the warning would need to be adjusted in those cases since
> the expression need not evaluate to true.)
>
> Martin
>
It's also not true if i is an IEEE floating point type with a NaN value.
In that case this is a standard idiom for testing for a NaN.
R.
More information about the Gcc-patches
mailing list