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: Steve Ellcey <sellcey at imgtec dot com>
- To: Marek Polacek <polacek at redhat dot com>
- Cc: Kyrill Tkachov <kyrylo dot tkachov at arm dot com>, Jeff Law <law at redhat dot com>, "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: Tue, 28 Jul 2015 09:02:51 -0700
- Subject: Re: [C/C++ PATCH] Implement -Wtautological-compare (PR c++/66555, c/54979)
- Authentication-results: sourceware.org; auth=none
- References: <20150727161041 dot GT3335 at redhat dot com>
- Reply-to: <sellcey at imgtec dot com>
Marek,
I have run into a problem with this warning and building glibc.
sysdeps/ieee754/s_matherr.c has:
int
weak_function
__matherr(struct exception *x)
{
int n=0;
if(x->arg1!=x->arg1) return 0;
return n;
}
And arg1 is a floating point type. I think that if the value of
x->xarg1 is a NaN then the if statement should return TRUE because a NaN
never compares equal to anything, even another NaN (check with your
local IEEE expert). I believe this method of checking for a NaN is
fairly common and I am not sure if GCC should be emitting a warning for
it.
Steve Ellcey
sellcey@imgtec.com