[PATCH] -Wtautological-compare should be quiet on floats
Marek Polacek
polacek@redhat.com
Thu Jul 30 10:00:00 GMT 2015
On Wed, Jul 29, 2015 at 04:44:46PM -0600, Jeff Law wrote:
> On 07/29/2015 08:08 AM, Marek Polacek wrote:
> >As discussed elsewhere, -Wtautological-compare shouldn't warn about
> >floating-point types because of the way NaN behave.
> >
> >I've been meaning to commit this one as obvious, but I'm not sure
> >whether I should also use HONOR_NANS or whether I can safely ignore
> >that here.
> >
> >Bootstrapped/regtested on x86_64-linux, ok for trunk?
> >
> >2015-07-29 Marek Polacek <polacek@redhat.com>
> >
> > * c-common.c (warn_tautological_cmp): Bail for float types.
> >
> > * c-c++-common/Wtautological-compare-3.c: New test.
> I think it comes down to what we think users are going to expect when
> compiling code with NaNs disabled.
>
> One camp would probably say "in my code X == X is always true since I don't
> have NaNs." The other might say "whether or not to warn on X == X should
> not be dependent on flags such as -ffinite-math-only".
>
> I could easily make a case for either. I'd personally tend to lean towards
> the latter.
Me too. I hope I won't upset anyone by committing this patch now. I just
don't want glibc folks to trip over this for too long.
Thanks,
Marek
More information about the Gcc-patches
mailing list