c99-math execute failures on sparc-sun-solaris2.11
Kaveh R. Ghazi
ghazi@caip.rutgers.edu
Tue Feb 5 20:59:00 GMT 2008
From: "Andreas Tobler" <andreast-list@fgznet.ch>
> Rainer Orth wrote:
>> In c99-math-double-1.c, the first C99_MATH_TESTS invocation abort()s.
>> Single-stepping in gdb (which couldn't display the macro, even if
>> compiled
>> with -g3 ;-) revealed that this clause
>>
>> if (fetestexcept (FE_ALL_EXCEPT) != 0) \
>> abort(); \
>>
>> fails. fetestexcept() returned 0x10, i.e. FE_INVALID.
>
> Argh, you've beaten me ;)
>
> The 'if (isinf (nan))' on line 62 of c99-math.h
> changes the exception, a fetestexception(FE_ALL_EXCEPT) after this if
> returns the 0x10. Before it was 0x0.
> Andreas
Okay, thanks both of you for tracking this down.
So the solaris definition of isinf is not exception-safe in the presence of
nans. Try inserting this code into c99-math-double-1.c after it includes
math headers. (This is what fixincludes puts into the header for solaris
10). See if it helps:
#undef isinf
#define isinf(x) __extension__ ({ const __typeof (x) __x_i = (x); \
__builtin_expect(sizeof(__x_i) == sizeof(float) \
? isgreater(__builtin_fabsf(__x_i),__FLT_MAX__) \
: sizeof(__x_i) == sizeof(long double) \
? isgreater(__builtin_fabsl(__x_i),__LDBL_MAX__) \
: isgreater(__builtin_fabs(__x_i),__DBL_MAX__), 0); })
It may pass isinf, but fail on a later if-abort. But hopefully this is the
only broken bit in that header on solaris.
--Kaveh
--
Kaveh R. Ghazi
More information about the Gcc
mailing list