1 /* Test NAN macro. Runtime exceptions test, to verify NaN is quiet
2 not signaling. */
3 /* { dg-do run } */
4 /* { dg-require-effective-target fenv_exceptions } */
5 /* { dg-options "-std=c2x -pedantic-errors" } */
6 /* { dg-add-options ieee } */
7
8 #include <fenv.h>
9 #include <float.h>
10
11 /* This should be defined if and only if quiet NaNs are supported for
12 type float. If the testsuite gains effective-target support for
13 targets not supporting NaNs, or not supporting them for all types,
14 this test should only be run for targets supporting quiet NaNs for
15 float. */
16 #ifndef NAN
17 #error "NAN undefined"
18 #endif
19
20 volatile float f = NAN;
21
22 extern void abort (void);
23 extern void exit (int);
24
25 int
main(void)26 main (void)
27 {
28 f += f;
29 if (fetestexcept (FE_INVALID))
30 abort ();
31 exit (0);
32 }
33