On Sat, 31 Aug 2013, Cong Hou wrote: > > I don't see why it would be unsafe for logb - can you give an example > > (exact float input value as hex float, and the values you believe logb > > should return for float and double). > > > > Please try the following code (you will get different results whether to > use optimization mode): > > #include <math.h> > #include <stdio.h> > > int main() > { > int i = 0x3edc67d5; > float f = *((float*)&i); > float r1 = logb(f); > float r2 = logbf(f); > printf("%x %x\n", *((int*)&r1), *((int*)&r2)); > }
(a) Please stop sending HTML email, so your messages reach the mailing list, and resend your messages so far to the list. The mailing list needs to see the whole of both sides of the discussion of any patch being proposed for GCC. (b) I referred to the values *you believe logb should return*. Optimization is not meant to preserve library bugs; the comparison should be on the basis of correctly rounded results from both float and double functions. The correct return from logb appears to be -2 here, and I get that from both logb and logbf with current git glibc. The existence of a bug in some old library is not relevant here. (c) I always advise writing such tests as *valid C code* using hex floats (or if really necessary, unions), not *invalid C code* with aliasing violations. -- Joseph S. Myers jos...@codesourcery.com