1 /* Tests of quiet not-a-number.
2 Copyright (C) 2023-2024 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* Written by Bruno Haible <bruno@clisp.org>, 2023. */
24 #if defined __GLIBC__ && defined __arm__ && defined __SOFTFP__
28 /* The arm software floating-point emulation (used e.g. on armv5) does not set
29 the floating-point exception bits. */
34 fputs ("Skipping test: software floating-point emulation\n", stderr
);
44 float volatile resultf
;
45 double volatile resultd
;
46 long double volatile resultl
;
51 /* Fetch the NaN values before we start watching out for FE_INVALID
52 exceptions, because the division 0.0 / 0.0 itself also raises an
54 The use of 'volatile' prevents the compiler from doing constant-folding
55 optimizations on these values. An alternative, for GCC only, would be
56 the command-line option '-fsignaling-nans'. */
57 float volatile nanf
= NaNf ();
58 double volatile nand
= NaNd ();
59 long double volatile nanl
= NaNl ();
61 /* Check that the values are really quiet. */
63 feclearexcept (FE_INVALID
);
64 resultf
= nanf
+ 42.0f
;
65 ASSERT (!fetestexcept (FE_INVALID
));
68 feclearexcept (FE_INVALID
);
69 resultd
= nand
+ 42.0;
70 ASSERT (!fetestexcept (FE_INVALID
));
73 feclearexcept (FE_INVALID
);
74 resultl
= nanl
+ 42.0L;
75 ASSERT (!fetestexcept (FE_INVALID
));
78 return test_exit_status
;