This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C/C++ PATCH] Implement -Wtautological-compare (PR c++/66555, c/54979)
- From: Marek Polacek <polacek at redhat dot com>
- To: Richard Earnshaw <Richard dot Earnshaw at foss dot arm dot com>
- Cc: Martin Sebor <msebor at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, Joseph Myers <joseph at codesourcery dot com>, Jason Merrill <jason at redhat dot com>
- Date: Wed, 29 Jul 2015 12:40:01 +0200
- Subject: Re: [C/C++ PATCH] Implement -Wtautological-compare (PR c++/66555, c/54979)
- Authentication-results: sourceware.org; auth=none
- References: <20150714151813 dot GA2363 at redhat dot com> <55AFE469 dot 30804 at gmail dot com> <55B8A40F dot 8090004 at foss dot arm dot com>
On Wed, Jul 29, 2015 at 10:59:43AM +0100, Richard Earnshaw wrote:
> 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.
Yep. Steve already raised this yesterday:
<https://gcc.gnu.org/ml/gcc-patches/2015-07/msg02388.html>
I'm going to fix it.
Thanks,
Marek