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: Steve Ellcey <sellcey at imgtec 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 20:55:04 +0200
- 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> <1438099371 dot 19674 dot 215 dot camel at ubuntu-sellcey>
On Tue, Jul 28, 2015 at 09:02:51AM -0700, Steve Ellcey wrote:
> 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.
Oh, you're right. In IEEE-754, NaN != NaN. So I need to adjust the
warning and the documentation a bit. I suppose this is just about
using get_inner_reference and punting for FLOAT_TYPE_P (I'll try to fix
this tomorrow).
This certainly didn't occur to me when I was writing the warning...
Thanks for bringing this up.
Marek