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: [C/C++ PATCH] Implement -Wtautological-compare (PR c++/66555, c/54979)


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


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