Add test case from a recent glibc bug.
[gnulib.git] / tests / minus-zero.h
blobb2cab2190c7f9365eeda87243506b87faf54483a
1 /* Macros for floating-point negative zero.
2 Copyright (C) 2010-2018 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 /* Keep in sync with m4/minus-zero.m4! */
19 #include <float.h>
22 /* minus_zerof represents the value -0.0f. */
24 /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0f.
25 ICC 10.0 has a bug when optimizing the expression -zero.
26 The expression -FLT_MIN * FLT_MIN does not work when cross-compiling
27 to PowerPC on Mac OS X 10.5. */
28 #if defined __hpux || defined __sgi || defined __ICC
29 static float
30 compute_minus_zerof (void)
32 return -FLT_MIN * FLT_MIN;
34 # define minus_zerof compute_minus_zerof ()
35 #else
36 float minus_zerof = -0.0f;
37 #endif
40 /* minus_zerod represents the value -0.0. */
42 /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
43 ICC 10.0 has a bug when optimizing the expression -zero.
44 The expression -DBL_MIN * DBL_MIN does not work when cross-compiling
45 to PowerPC on Mac OS X 10.5. */
46 #if defined __hpux || defined __sgi || defined __ICC
47 static double
48 compute_minus_zerod (void)
50 return -DBL_MIN * DBL_MIN;
52 # define minus_zerod compute_minus_zerod ()
53 #else
54 double minus_zerod = -0.0;
55 #endif
58 /* minus_zerol represents the value -0.0L. */
60 /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0L.
61 IRIX cc can't put -0.0L into .data, but can compute at runtime.
62 ICC 10.0 has a bug when optimizing the expression -zero.
63 The expression -LDBL_MIN * LDBL_MIN does not work when cross-compiling
64 to PowerPC on Mac OS X 10.5. */
65 #if defined __hpux || defined __sgi || defined __ICC
66 static long double
67 compute_minus_zerol (void)
69 return -LDBL_MIN * LDBL_MIN;
71 # define minus_zerol compute_minus_zerol ()
72 #else
73 long double minus_zerol = -0.0L;
74 #endif