The following code fails because __builtin_nansl generates a quiet NaN: extern int __issignaling (double); int main (void) { double sNaN = __builtin_nansl (""); if (!__issignaling(sNaN)) return 1; return 0; } .LC0: .word 2146959359 .word -1 (gdb) p/x 2146959359 $1 = 0x7ff7ffff This is a quiet NaN on PA-RISC. __builtin_nans() correctly generates a signaling NaN. long double and double are the same on hppa-linux. The problem causes several glibc testsuite failures.
This seems quite tricky. Conversion changes a signaling nan to a quiet nan: /* Make resulting NaN value to be qNaN. The caller has the responsibility to avoid the operation if flag_signaling_nans is on. */ if (r->cl == rvc_nan) r->signalling = 0; But the following results in a signaling nan: extern int __issignaling (double); int main (void) { long double sNaN = __builtin_nansl (""); if (!__issignaling((double)sNaN)) return 1; return 0; }
If the original testcase is compiled with -fsignaling-nans, the signaling nan is not converted to a quiet nan. Thus, I believe the conversion is expected. There might be an issue with the second testcase.
Of course, such a test is fairly meaningless without -fsignaling-nans. Then, where long double and double have the same format, "Whether C assignment (6.5.16) (and conversion as if by assignment) to the same format is an IEC 60559 convertFormat or copy operation is implementation-defined, even if <fenv.h> defines the macro FE_SNANS_ALWAYS_SIGNAL (F.2.1)." from TS 18661-1 applies. That is, a test should not be expecting a particular choice of the signaling NaN being quieted or not by a conversion to the same format, including when that's a conversion from long double to double (and GCC will generally not quiet the signaling NaN in such a conversion, unless on an excess-precision architecture where simple loads of the narrower type quiet it).
On 2017-06-19 1:32 PM, joseph at codesourcery dot com wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81120 > > --- Comment #3 from joseph at codesourcery dot com <joseph at codesourcery dot com> --- > Of course, such a test is fairly meaningless without -fsignaling-nans. The failing glibc tests mentioned in math/21607 do not have -fsignaling-nans but adding it didn't affect the result for basic-test. Need to simplify the test to get an accurate testcase. > > Then, where long double and double have the same format, "Whether C > assignment (6.5.16) (and conversion as if by assignment) to the same > format is an IEC 60559 convertFormat or copy operation is > implementation-defined, even if <fenv.h> defines the macro Is there a gcc option to select between convertFormat and copy? Loads do not quiet signaling NaNs on PA-RISC, so I think a "copy" operation would be preferred. I believe __issignaling() is used for both double and long double in hppa glibc.
On Mon, 19 Jun 2017, dave.anglin at bell dot net wrote: > Is there a gcc option to select between convertFormat and copy? Loads do There is no such option.
Given Joseph's comments, closing.