This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] -Wtautological-compare should be quiet on floats


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.

Jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]