The attached program, when compiled with "gcc -O2" (gcc version >= 4.4), returns with exit code 0 without ever invoking the exp2l() function. Apparently GCC knows about identities for <math.h> functions. A 'volatile' keyword is necessary to disable these identity-based optimizations.
For reliability, add this 'volatile' keyword in the idiom of these autoconf tests. 2019-01-20 Bruno Haible <br...@clisp.org> Defeat current GCC optimizations in math autoconf tests. * m4/cbrtl.m4 (gl_FUNC_CBRTL): Mark function pointer as 'volatile'. * m4/ceil.m4 (gl_FUNC_CEIL): Likewise. * m4/ceilf.m4 (gl_FUNC_CEILF): Likewise. * m4/ceill.m4 (gl_FUNC_CEILL): Likewise. * m4/exp2l.m4 (gl_FUNC_EXP2L): Likewise. * m4/expm1.m4 (gl_FUNC_EXPM1): Likewise. * m4/floor.m4 (gl_FUNC_FLOOR): Likewise. * m4/floorf.m4 (gl_FUNC_FLOORF): Likewise. * m4/fmod.m4 (gl_FUNC_FMOD): Likewise. * m4/fmodf.m4 (gl_FUNC_FMODF): Likewise. * m4/fmodl.m4 (gl_FUNC_FMODL): Likewise. * m4/hypot.m4 (gl_FUNC_HYPOT): Likewise. * m4/hypotf.m4 (gl_FUNC_HYPOTF): Likewise. * m4/hypotl.m4 (gl_FUNC_HYPOTL): Likewise. * m4/ilogb.m4 (gl_FUNC_ILOGB_WORKS): Likewise. * m4/ilogbf.m4 (gl_FUNC_ILOGBF_WORKS): Likewise. * m4/ilogbl.m4 (gl_FUNC_ILOGBL_WORKS): Likewise. * m4/log.m4 (gl_FUNC_LOG): Likewise. * m4/logf.m4 (gl_FUNC_LOGF): Likewise. * m4/log10.m4 (gl_FUNC_LOG10): Likewise. * m4/log10f.m4 (gl_FUNC_LOG10F): Likewise. * m4/log1p.m4 (gl_FUNC_LOG1P): Likewise. * m4/log1pf.m4 (gl_FUNC_LOG1PF): Likewise. * m4/log1pl.m4 (gl_FUNC_LOG1PL): Likewise. * m4/log2.m4 (gl_FUNC_LOG2): Likewise. * m4/log2f.m4 (gl_FUNC_LOG2F): Likewise. * m4/modf.m4 (gl_FUNC_MODF): Likewise. * m4/modff.m4 (gl_FUNC_MODFF): Likewise. * m4/modfl.m4 (gl_FUNC_MODFL): Likewise. * m4/remainder.m4 (gl_FUNC_REMAINDER): Likewise. * m4/remainderf.m4 (gl_FUNC_REMAINDERF): Likewise. * m4/remainderl.m4 (gl_FUNC_REMAINDERL): Likewise. * m4/round.m4 (gl_FUNC_ROUND): Likewise. * m4/roundf.m4 (gl_FUNC_ROUNDF): Likewise. * m4/roundl.m4 (gl_FUNC_ROUNDL): Likewise. * m4/trunc.m4 (gl_FUNC_TRUNC): Likewise. * m4/truncf.m4 (gl_FUNC_TRUNCF): Likewise. * m4/truncl.m4 (gl_FUNC_TRUNCL): Likewise. diff --git a/m4/cbrtl.m4 b/m4/cbrtl.m4 index e0f7362..dc867db 100644 --- a/m4/cbrtl.m4 +++ b/m4/cbrtl.m4 @@ -1,4 +1,4 @@ -# cbrtl.m4 serial 7 +# cbrtl.m4 serial 8 dnl Copyright (C) 2012-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -59,7 +59,7 @@ int main (int argc, char *argv[]) "C" #endif long double cbrtl (long double); - long double (*my_cbrtl) (long double) = argc ? cbrtl : dummy; + long double (* volatile my_cbrtl) (long double) = argc ? cbrtl : dummy; long double f; /* Test cbrtl(-0.0). This test fails on IRIX 6.5. */ diff --git a/m4/ceil.m4 b/m4/ceil.m4 index 1b11b84..5522284 100644 --- a/m4/ceil.m4 +++ b/m4/ceil.m4 @@ -1,4 +1,4 @@ -# ceil.m4 serial 12 +# ceil.m4 serial 13 dnl Copyright (C) 2007, 2009-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -32,7 +32,7 @@ AC_DEFUN([gl_FUNC_CEIL], static double dummy (double f) { return 0; } int main (int argc, char *argv[]) { - double (*my_ceil) (double) = argc ? ceil : dummy; + double (* volatile my_ceil) (double) = argc ? ceil : dummy; int result = 0; /* Test whether ceil (-0.0) is -0.0. */ if (signbitd (minus_zerod) && !signbitd (my_ceil (minus_zerod))) diff --git a/m4/ceilf.m4 b/m4/ceilf.m4 index de4a809..65b4cff 100644 --- a/m4/ceilf.m4 +++ b/m4/ceilf.m4 @@ -1,4 +1,4 @@ -# ceilf.m4 serial 16 +# ceilf.m4 serial 17 dnl Copyright (C) 2007, 2009-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -39,7 +39,7 @@ AC_DEFUN([gl_FUNC_CEILF], static float dummy (float f) { return 0; } int main (int argc, char *argv[]) { - float (*my_ceilf) (float) = argc ? ceilf : dummy; + float (* volatile my_ceilf) (float) = argc ? ceilf : dummy; int result = 0; /* Test whether ceilf (-0.0f) is -0.0f. */ if (signbitf (minus_zerof) && !signbitf (my_ceilf (minus_zerof))) diff --git a/m4/ceill.m4 b/m4/ceill.m4 index 2663d4c..863c344 100644 --- a/m4/ceill.m4 +++ b/m4/ceill.m4 @@ -1,4 +1,4 @@ -# ceill.m4 serial 17 +# ceill.m4 serial 18 dnl Copyright (C) 2007, 2009-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -42,7 +42,7 @@ AC_DEFUN([gl_FUNC_CEILL], static long double dummy (long double f) { return 0; } int main (int argc, char *argv[]) { - long double (*my_ceill) (long double) = argc ? ceill : dummy; + long double (* volatile my_ceill) (long double) = argc ? ceill : dummy; /* Test whether ceill (-0.3L) is -0.0L. */ if (signbitl (minus_zerol) && !signbitl (my_ceill (-0.3L))) return 1; diff --git a/m4/exp2l.m4 b/m4/exp2l.m4 index d687e7d..20630cc 100644 --- a/m4/exp2l.m4 +++ b/m4/exp2l.m4 @@ -1,4 +1,4 @@ -# exp2l.m4 serial 5 +# exp2l.m4 serial 6 dnl Copyright (C) 2010-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -50,7 +50,7 @@ static long double dummy (long double x) { return 0; } static long double zero; int main (int argc, char *argv[]) { - long double (*my_exp2l) (long double) = argc ? exp2l : dummy; + long double (* volatile my_exp2l) (long double) = argc ? exp2l : dummy; int result = 0; /* This test fails on OpenBSD 4.9, where exp2l(NaN) = 0.0. */ if (exp2l (zero / zero) == 0.0L) diff --git a/m4/expm1.m4 b/m4/expm1.m4 index 789f9ac..fcea1df 100644 --- a/m4/expm1.m4 +++ b/m4/expm1.m4 @@ -1,4 +1,4 @@ -# expm1.m4 serial 5 +# expm1.m4 serial 6 dnl Copyright (C) 2010-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -75,7 +75,7 @@ AC_DEFUN([gl_FUNC_EXPM1], static double dummy (double x) { return 0; } int main (int argc, char *argv[]) { - double (*my_expm1) (double) = argc ? expm1 : dummy; + double (* volatile my_expm1) (double) = argc ? expm1 : dummy; double y = my_expm1 (minus_zerod); if (!(y == 0.0) || (signbitd (minus_zerod) && !signbitd (y))) return 1; diff --git a/m4/floor.m4 b/m4/floor.m4 index 25a80b9..7b3d965 100644 --- a/m4/floor.m4 +++ b/m4/floor.m4 @@ -1,4 +1,4 @@ -# floor.m4 serial 11 +# floor.m4 serial 12 dnl Copyright (C) 2007, 2009-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -32,7 +32,7 @@ AC_DEFUN([gl_FUNC_FLOOR], static double dummy (double f) { return 0; } int main (int argc, char *argv[]) { - double (*my_floor) (double) = argc ? floor : dummy; + double (* volatile my_floor) (double) = argc ? floor : dummy; /* Test whether floor (-0.0) is -0.0. */ if (signbitd (minus_zerod) && !signbitd (my_floor (minus_zerod))) return 1; diff --git a/m4/floorf.m4 b/m4/floorf.m4 index 6713df8..5fad8a5 100644 --- a/m4/floorf.m4 +++ b/m4/floorf.m4 @@ -1,4 +1,4 @@ -# floorf.m4 serial 15 +# floorf.m4 serial 16 dnl Copyright (C) 2007, 2009-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -39,7 +39,7 @@ AC_DEFUN([gl_FUNC_FLOORF], static float dummy (float f) { return 0; } int main (int argc, char *argv[]) { - float (*my_floorf) (float) = argc ? floorf : dummy; + float (* volatile my_floorf) (float) = argc ? floorf : dummy; /* Test whether floorf (-0.0f) is -0.0f. */ if (signbitf (minus_zerof) && !signbitf (my_floorf (minus_zerof))) return 1; diff --git a/m4/fmod.m4 b/m4/fmod.m4 index 0b61649..898e9e8 100644 --- a/m4/fmod.m4 +++ b/m4/fmod.m4 @@ -1,4 +1,4 @@ -# fmod.m4 serial 6 +# fmod.m4 serial 7 dnl Copyright (C) 2011-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -39,7 +39,7 @@ numeric_equal (double x, double y) static double dummy (double x, double y) { return 0; } int main (int argc, char *argv[]) { - double (*my_fmod) (double, double) = argc ? fmod : dummy; + double (* volatile my_fmod) (double, double) = argc ? fmod : dummy; int result = 0; double f; /* Test fmod(...,0.0). diff --git a/m4/fmodf.m4 b/m4/fmodf.m4 index 5a6d7da..42c64ab 100644 --- a/m4/fmodf.m4 +++ b/m4/fmodf.m4 @@ -1,4 +1,4 @@ -# fmodf.m4 serial 8 +# fmodf.m4 serial 9 dnl Copyright (C) 2011-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -46,7 +46,7 @@ numeric_equal (float x, float y) static float dummy (float x, float y) { return 0; } int main (int argc, char *argv[]) { - float (*my_fmodf) (float, float) = argc ? fmodf : dummy; + float (* volatile my_fmodf) (float, float) = argc ? fmodf : dummy; float f; /* Test fmodf(...,0.0f). This test fails on OSF/1 5.1. */ diff --git a/m4/fmodl.m4 b/m4/fmodl.m4 index 8d32031..1e3e9aa 100644 --- a/m4/fmodl.m4 +++ b/m4/fmodl.m4 @@ -1,4 +1,4 @@ -# fmodl.m4 serial 8 +# fmodl.m4 serial 9 dnl Copyright (C) 2011-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -57,7 +57,7 @@ numeric_equal (long double x, long double y) static long double dummy (long double x, long double y) { return 0; } int main (int argc, char *argv[]) { - long double (*my_fmodl) (long double, long double) = argc ? fmodl : dummy; + long double (* volatile my_fmodl) (long double, long double) = argc ? fmodl : dummy; long double f; /* Test fmodl(...,0.0L). This test fails on OSF/1 5.1. */ diff --git a/m4/hypot.m4 b/m4/hypot.m4 index 713dfa2..a7242a2 100644 --- a/m4/hypot.m4 +++ b/m4/hypot.m4 @@ -1,4 +1,4 @@ -# hypot.m4 serial 6 +# hypot.m4 serial 7 dnl Copyright (C) 2012-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -42,7 +42,7 @@ double zero; double one = 1.0; int main (int argc, char *argv[]) { - double (*my_hypot) (double, double) = argc ? hypot : dummy; + double (* volatile my_hypot) (double, double) = argc ? hypot : dummy; double f; /* Test hypot(NaN,Infinity). This test fails on OSF/1 5.1 and native Windows. */ diff --git a/m4/hypotf.m4 b/m4/hypotf.m4 index 9e0773e..80da9ae 100644 --- a/m4/hypotf.m4 +++ b/m4/hypotf.m4 @@ -1,4 +1,4 @@ -# hypotf.m4 serial 7 +# hypotf.m4 serial 8 dnl Copyright (C) 2012-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -58,7 +58,7 @@ float zero; float one = 1.0f; int main (int argc, char *argv[]) { - float (*my_hypotf) (float, float) = argc ? hypotf : dummy; + float (* volatile my_hypotf) (float, float) = argc ? hypotf : dummy; float f; /* Test hypotf(NaN,Infinity). This test fails on OSF/1 5.1 and native Windows. */ diff --git a/m4/hypotl.m4 b/m4/hypotl.m4 index 45cc999..dcced7e 100644 --- a/m4/hypotl.m4 +++ b/m4/hypotl.m4 @@ -1,4 +1,4 @@ -# hypotl.m4 serial 8 +# hypotl.m4 serial 9 dnl Copyright (C) 2012-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -58,7 +58,7 @@ long double zero; long double one = 1.0L; int main (int argc, char *argv[]) { - long double (*my_hypotl) (long double, long double) = argc ? hypotl : dummy; + long double (* volatile my_hypotl) (long double, long double) = argc ? hypotl : dummy; long double f; /* Test hypotl(NaN,Infinity). This test fails on OSF/1 5.1 and native Windows. */ diff --git a/m4/ilogb.m4 b/m4/ilogb.m4 index 67d9d22..53c3f05 100644 --- a/m4/ilogb.m4 +++ b/m4/ilogb.m4 @@ -1,4 +1,4 @@ -# ilogb.m4 serial 3 +# ilogb.m4 serial 4 dnl Copyright (C) 2010-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -85,7 +85,7 @@ static double zero; static int dummy (double x) { return 0; } int main (int argc, char *argv[]) { - int (*my_ilogb) (double) = argc ? ilogb : dummy; + int (* volatile my_ilogb) (double) = argc ? ilogb : dummy; int result = 0; /* This test fails on OpenBSD 4.9, AIX 5.1. */ { diff --git a/m4/ilogbf.m4 b/m4/ilogbf.m4 index 9874006..cf0ebe4 100644 --- a/m4/ilogbf.m4 +++ b/m4/ilogbf.m4 @@ -1,4 +1,4 @@ -# ilogbf.m4 serial 3 +# ilogbf.m4 serial 4 dnl Copyright (C) 2010-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -87,7 +87,7 @@ static float zero; static int dummy (float x) { return 0; } int main (int argc, char *argv[]) { - int (*my_ilogbf) (float) = argc ? ilogbf : dummy; + int (* volatile my_ilogbf) (float) = argc ? ilogbf : dummy; int result = 0; /* This test fails on OpenBSD 4.9. */ { diff --git a/m4/ilogbl.m4 b/m4/ilogbl.m4 index a164698..c8ba52a 100644 --- a/m4/ilogbl.m4 +++ b/m4/ilogbl.m4 @@ -1,4 +1,4 @@ -# ilogbl.m4 serial 2 +# ilogbl.m4 serial 3 dnl Copyright (C) 2010-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -106,7 +106,7 @@ volatile long double x; static int dummy (long double x) { return 0; } int main (int argc, char *argv[]) { - int (*my_ilogbl) (long double) = argc ? ilogbl : dummy; + int (* volatile my_ilogbl) (long double) = argc ? ilogbl : dummy; int result = 0; /* This test fails on Haiku 2017. */ { diff --git a/m4/log.m4 b/m4/log.m4 index b02acb6..a4e2a5c 100644 --- a/m4/log.m4 +++ b/m4/log.m4 @@ -1,4 +1,4 @@ -# log.m4 serial 8 +# log.m4 serial 9 dnl Copyright (C) 2011-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -46,7 +46,7 @@ numeric_equal (double x, double y) static double dummy (double x) { return 0; } int main (int argc, char *argv[]) { - double (*my_log) (double) = argc ? log : dummy; + double (* volatile my_log) (double) = argc ? log : dummy; /* Test log(negative). This test fails on NetBSD 5.1, Solaris 11.4. */ double y = my_log (-1.0); diff --git a/m4/log10.m4 b/m4/log10.m4 index 102683b..6af6624 100644 --- a/m4/log10.m4 +++ b/m4/log10.m4 @@ -1,4 +1,4 @@ -# log10.m4 serial 8 +# log10.m4 serial 9 dnl Copyright (C) 2011-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -46,7 +46,7 @@ numeric_equal (double x, double y) static double dummy (double x) { return 0; } int main (int argc, char *argv[]) { - double (*my_log10) (double) = argc ? log10 : dummy; + double (* volatile my_log10) (double) = argc ? log10 : dummy; /* Test log10(negative). This test fails on NetBSD 5.1, Solaris 11.4. */ double y = my_log10 (-1.0); diff --git a/m4/log10f.m4 b/m4/log10f.m4 index 1d9ee61..47501dd 100644 --- a/m4/log10f.m4 +++ b/m4/log10f.m4 @@ -1,4 +1,4 @@ -# log10f.m4 serial 9 +# log10f.m4 serial 10 dnl Copyright (C) 2011-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -56,7 +56,7 @@ numeric_equal (float x, float y) static float dummy (float x) { return 0; } int main (int argc, char *argv[]) { - float (*my_log10f) (float) = argc ? log10f : dummy; + float (* volatile my_log10f) (float) = argc ? log10f : dummy; /* Test log10f(negative). This test fails on NetBSD 5.1. */ float y = my_log10f (-1.0f); diff --git a/m4/log1p.m4 b/m4/log1p.m4 index 864a6d8..b5dd430 100644 --- a/m4/log1p.m4 +++ b/m4/log1p.m4 @@ -1,4 +1,4 @@ -# log1p.m4 serial 5 +# log1p.m4 serial 6 dnl Copyright (C) 2012-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -41,7 +41,7 @@ AC_DEFUN([gl_FUNC_LOG1P], static double dummy (double x) { return 0; } int main (int argc, char *argv[]) { - double (*my_log1p) (double) = argc ? log1p : dummy; + double (* volatile my_log1p) (double) = argc ? log1p : dummy; /* This test fails on AIX, HP-UX 11. */ double y = my_log1p (minus_zerod); if (!(y == 0.0) || (signbitd (minus_zerod) && !signbitd (y))) diff --git a/m4/log1pf.m4 b/m4/log1pf.m4 index f4055f8..4a2c35a 100644 --- a/m4/log1pf.m4 +++ b/m4/log1pf.m4 @@ -1,4 +1,4 @@ -# log1pf.m4 serial 5 +# log1pf.m4 serial 6 dnl Copyright (C) 2012-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -50,7 +50,7 @@ AC_DEFUN([gl_FUNC_LOG1PF], static float dummy (float x) { return 0; } int main (int argc, char *argv[]) { - float (*my_log1pf) (float) = argc ? log1pf : dummy; + float (* volatile my_log1pf) (float) = argc ? log1pf : dummy; /* This test fails on OpenBSD 4.9, AIX 7.1. */ float y = my_log1pf (minus_zerof); if (!(y == 0.0f) || (signbitf (minus_zerof) && !signbitf (y))) diff --git a/m4/log1pl.m4 b/m4/log1pl.m4 index 462c0e5..7def391 100644 --- a/m4/log1pl.m4 +++ b/m4/log1pl.m4 @@ -1,4 +1,4 @@ -# log1pl.m4 serial 5 +# log1pl.m4 serial 6 dnl Copyright (C) 2012-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -41,7 +41,7 @@ AC_DEFUN([gl_FUNC_LOG1PL], static long double dummy (long double x) { return 0; } int main (int argc, char *argv[]) { - long double (*my_log1pl) (long double) = argc ? log1pl : dummy; + long double (* volatile my_log1pl) (long double) = argc ? log1pl : dummy; /* This test fails on AIX 7.1, IRIX 6.5. */ long double y = my_log1pl (minus_zerol); if (!(y == 0.0L) || (signbitl (minus_zerol) && !signbitl (y))) diff --git a/m4/log2.m4 b/m4/log2.m4 index 7fd56fa..bd8b3cf 100644 --- a/m4/log2.m4 +++ b/m4/log2.m4 @@ -1,4 +1,4 @@ -# log2.m4 serial 7 +# log2.m4 serial 8 dnl Copyright (C) 2010-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -67,7 +67,7 @@ numeric_equal (double x, double y) static double dummy (double x) { return 0; } int main (int argc, char *argv[]) { - double (*my_log2) (double) = argc ? log2 : dummy; + double (* volatile my_log2) (double) = argc ? log2 : dummy; /* Test log2(negative). This test fails on NetBSD 5.1 and Solaris 10/x86_64. */ double y = my_log2 (-1.0); diff --git a/m4/log2f.m4 b/m4/log2f.m4 index b294b7f..63b8458 100644 --- a/m4/log2f.m4 +++ b/m4/log2f.m4 @@ -1,4 +1,4 @@ -# log2f.m4 serial 7 +# log2f.m4 serial 8 dnl Copyright (C) 2010-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -68,7 +68,7 @@ numeric_equal (float x, float y) static float dummy (float x) { return 0; } int main (int argc, char *argv[]) { - float (*my_log2f) (float) = argc ? log2f : dummy; + float (* volatile my_log2f) (float) = argc ? log2f : dummy; /* Test log2f(negative). This test fails on NetBSD 5.1 and Solaris 10/x86_64. */ float y = my_log2f (-1.0f); diff --git a/m4/logf.m4 b/m4/logf.m4 index ac0aab7..6b9e5bb 100644 --- a/m4/logf.m4 +++ b/m4/logf.m4 @@ -1,4 +1,4 @@ -# logf.m4 serial 9 +# logf.m4 serial 10 dnl Copyright (C) 2011-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -56,7 +56,7 @@ numeric_equal (float x, float y) static float dummy (float x) { return 0; } int main (int argc, char *argv[]) { - float (*my_logf) (float) = argc ? logf : dummy; + float (* volatile my_logf) (float) = argc ? logf : dummy; /* Test logf(negative). This test fails on NetBSD 5.1. */ float y = my_logf (-1.0f); diff --git a/m4/modf.m4 b/m4/modf.m4 index 6d86d32..b503844 100644 --- a/m4/modf.m4 +++ b/m4/modf.m4 @@ -1,4 +1,4 @@ -# modf.m4 serial 5 +# modf.m4 serial 6 dnl Copyright (C) 2011-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -41,7 +41,7 @@ double zero; double minus_one = - 1.0; int main (int argc, char *argv[]) { - double (*my_modf) (double, double *) = argc ? modf : dummy; + double (* volatile my_modf) (double, double *) = argc ? modf : dummy; int result = 0; double i; double f; diff --git a/m4/modff.m4 b/m4/modff.m4 index c7b2a17..e1fbf1d 100644 --- a/m4/modff.m4 +++ b/m4/modff.m4 @@ -1,4 +1,4 @@ -# modff.m4 serial 7 +# modff.m4 serial 8 dnl Copyright (C) 2011-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -49,7 +49,7 @@ float zero; float minus_one = - 1.0f; int main (int argc, char *argv[]) { - float (*my_modff) (float, float *) = argc ? modff : dummy; + float (* volatile my_modff) (float, float *) = argc ? modff : dummy; int result = 0; float i; float f; diff --git a/m4/modfl.m4 b/m4/modfl.m4 index 8b5bc7b..fc32cd64 100644 --- a/m4/modfl.m4 +++ b/m4/modfl.m4 @@ -1,4 +1,4 @@ -# modfl.m4 serial 5 +# modfl.m4 serial 6 dnl Copyright (C) 2011-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -49,7 +49,7 @@ long double zero; long double minus_one = - 1.0L; int main (int argc, char *argv[]) { - long double (*my_modfl) (long double, long double *) = argc ? modfl : dummy; + long double (* volatile my_modfl) (long double, long double *) = argc ? modfl : dummy; long double i; long double f; /* Test modfl(-Inf,...). diff --git a/m4/remainder.m4 b/m4/remainder.m4 index 0e9d19e..58548ba 100644 --- a/m4/remainder.m4 +++ b/m4/remainder.m4 @@ -1,4 +1,4 @@ -# remainder.m4 serial 6 +# remainder.m4 serial 7 dnl Copyright (C) 2012-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -79,7 +79,7 @@ numeric_equal (double x, double y) static double dummy (double x, double y) { return 0; } int main (int argc, char *argv[]) { - double (*my_remainder) (double, double) = argc ? remainder : dummy; + double (* volatile my_remainder) (double, double) = argc ? remainder : dummy; double f; /* Test remainder(...,0.0). This test fails on OSF/1 5.1. */ diff --git a/m4/remainderf.m4 b/m4/remainderf.m4 index ff4e98d..5ab511a 100644 --- a/m4/remainderf.m4 +++ b/m4/remainderf.m4 @@ -1,4 +1,4 @@ -# remainderf.m4 serial 10 +# remainderf.m4 serial 11 dnl Copyright (C) 2012-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -82,7 +82,7 @@ numeric_equal (float x, float y) static float dummy (float x, float y) { return 0; } int main (int argc, char *argv[]) { - float (*my_remainderf) (float, float) = argc ? remainderf : dummy; + float (* volatile my_remainderf) (float, float) = argc ? remainderf : dummy; float f; /* Test remainderf(...,0.0f). This test fails on OSF/1 5.1. */ diff --git a/m4/remainderl.m4 b/m4/remainderl.m4 index cfa94f5..85ed6be 100644 --- a/m4/remainderl.m4 +++ b/m4/remainderl.m4 @@ -1,4 +1,4 @@ -# remainderl.m4 serial 9 +# remainderl.m4 serial 10 dnl Copyright (C) 2012-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -87,7 +87,7 @@ numeric_equal (long double x, long double y) static long double dummy (long double x, long double y) { return 0; } int main (int argc, char *argv[]) { - long double (*my_remainderl) (long double, long double) = argc ? remainderl : dummy; + long double (* volatile my_remainderl) (long double, long double) = argc ? remainderl : dummy; long double f; /* Test remainderl(...,0.0L). This test fails on OSF/1 5.1. */ diff --git a/m4/round.m4 b/m4/round.m4 index cbc9f02..49ae315 100644 --- a/m4/round.m4 +++ b/m4/round.m4 @@ -1,4 +1,4 @@ -# round.m4 serial 19 +# round.m4 serial 20 dnl Copyright (C) 2007, 2009-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -103,7 +103,7 @@ double round (double); static double dummy (double f) { return 0; } int main (int argc, char *argv[]) { - double (*my_round) (double) = argc ? round : dummy; + double (* volatile my_round) (double) = argc ? round : dummy; /* Test whether round (-0.0) is -0.0. */ if (signbitd (minus_zerod) && !signbitd (my_round (minus_zerod))) return 1; diff --git a/m4/roundf.m4 b/m4/roundf.m4 index e0530ba..07f816e 100644 --- a/m4/roundf.m4 +++ b/m4/roundf.m4 @@ -1,4 +1,4 @@ -# roundf.m4 serial 20 +# roundf.m4 serial 21 dnl Copyright (C) 2007-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -99,7 +99,7 @@ float roundf (float); static float dummy (float f) { return 0; } int main (int argc, char *argv[]) { - float (*my_roundf) (float) = argc ? roundf : dummy; + float (* volatile my_roundf) (float) = argc ? roundf : dummy; int result = 0; /* Test whether roundf (-0.0f) is -0.0f. */ if (signbitf (minus_zerof) && !signbitf (my_roundf (minus_zerof))) diff --git a/m4/roundl.m4 b/m4/roundl.m4 index 0bc0391..95eed1b 100644 --- a/m4/roundl.m4 +++ b/m4/roundl.m4 @@ -1,4 +1,4 @@ -# roundl.m4 serial 17 +# roundl.m4 serial 18 dnl Copyright (C) 2007, 2009-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -50,7 +50,7 @@ long double roundl (long double); static long double dummy (long double f) { return 0; } int main (int argc, char *argv[]) { - long double (*my_roundl) (long double) = argc ? roundl : dummy; + long double (* volatile my_roundl) (long double) = argc ? roundl : dummy; int result = 0; /* Test whether roundl (-0.0L) is -0.0L. */ if (signbitl (minus_zerol) && !signbitl (my_roundl (minus_zerol))) diff --git a/m4/trunc.m4 b/m4/trunc.m4 index ef8d59b..056d56d 100644 --- a/m4/trunc.m4 +++ b/m4/trunc.m4 @@ -1,4 +1,4 @@ -# trunc.m4 serial 12 +# trunc.m4 serial 13 dnl Copyright (C) 2007, 2010-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -62,7 +62,7 @@ AC_DEFUN([gl_FUNC_TRUNC], static double dummy (double f) { return 0; } int main (int argc, char *argv[]) { - double (*my_trunc) (double) = argc ? trunc : dummy; + double (* volatile my_trunc) (double) = argc ? trunc : dummy; /* Test whether trunc (-0.0) is -0.0. */ if (signbitd (minus_zerod) && !signbitd (my_trunc (minus_zerod))) return 1; diff --git a/m4/truncf.m4 b/m4/truncf.m4 index af6eeeb..1ee987b 100644 --- a/m4/truncf.m4 +++ b/m4/truncf.m4 @@ -1,4 +1,4 @@ -# truncf.m4 serial 12 +# truncf.m4 serial 13 dnl Copyright (C) 2007, 2010-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -62,7 +62,7 @@ AC_DEFUN([gl_FUNC_TRUNCF], static float dummy (float f) { return 0; } int main (int argc, char *argv[]) { - float (*my_truncf) (float) = argc ? truncf : dummy; + float (* volatile my_truncf) (float) = argc ? truncf : dummy; /* Test whether truncf (-0.0f) is -0.0f. */ if (signbitf (minus_zerof) && !signbitf (my_truncf (minus_zerof))) return 1; diff --git a/m4/truncl.m4 b/m4/truncl.m4 index 65f1fce..b03d04c 100644 --- a/m4/truncl.m4 +++ b/m4/truncl.m4 @@ -1,4 +1,4 @@ -# truncl.m4 serial 14 +# truncl.m4 serial 15 dnl Copyright (C) 2007-2008, 2010-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -95,7 +95,7 @@ int main() static long double dummy (long double f) { return 0; } int main (int argc, char *argv[]) { - long double (*my_truncl) (long double) = argc ? truncl : dummy; + long double (* volatile my_truncl) (long double) = argc ? truncl : dummy; /* Test whether truncl (-0.3L) is -0.0L. */ if (signbitl (minus_zerol) && !signbitl (my_truncl (-0.3L))) return 1;
#ifndef __NO_MATH_INLINES # define __NO_MATH_INLINES 1 /* for glibc */ #endif #include <float.h> #include <math.h> /* Override the values of <float.h>, like done in float.in.h. */ #if defined __i386__ && (defined __BEOS__ || defined __OpenBSD__) # undef LDBL_MANT_DIG # define LDBL_MANT_DIG 64 # undef LDBL_MIN_EXP # define LDBL_MIN_EXP (-16381) # undef LDBL_MAX_EXP # define LDBL_MAX_EXP 16384 #endif #if defined __i386__ && (defined __FreeBSD__ || defined __DragonFly__) # undef LDBL_MANT_DIG # define LDBL_MANT_DIG 64 # undef LDBL_MIN_EXP # define LDBL_MIN_EXP (-16381) # undef LDBL_MAX_EXP # define LDBL_MAX_EXP 16384 #endif #if (defined _ARCH_PPC || defined _POWER) && defined _AIX && (LDBL_MANT_DIG == 106) && defined __GNUC__ # undef LDBL_MIN_EXP # define LDBL_MIN_EXP DBL_MIN_EXP #endif #if defined __sgi && (LDBL_MANT_DIG >= 106) # undef LDBL_MANT_DIG # define LDBL_MANT_DIG 106 # if defined __GNUC__ # undef LDBL_MIN_EXP # define LDBL_MIN_EXP DBL_MIN_EXP # endif #endif #undef exp2l extern #ifdef __cplusplus "C" #endif long double exp2l (long double); static long double dummy (long double x) { return 0; } static long double zero; int main (int argc, char *argv[]) { long double (*my_exp2l) (long double) = argc ? exp2l : dummy; int result = 0; /* This test fails on NetBSD 8.0. */ { const long double TWO_LDBL_MANT_DIG = /* 2^LDBL_MANT_DIG */ (long double) (1U << ((LDBL_MANT_DIG - 1) / 5)) * (long double) (1U << ((LDBL_MANT_DIG - 1 + 1) / 5)) * (long double) (1U << ((LDBL_MANT_DIG - 1 + 2) / 5)) * (long double) (1U << ((LDBL_MANT_DIG - 1 + 3) / 5)) * (long double) (1U << ((LDBL_MANT_DIG - 1 + 4) / 5)); long double x = 11.358L; long double err = (my_exp2l (x) * my_exp2l (- x) - 1.0L) * TWO_LDBL_MANT_DIG; if (!(err >= -100.0L && err <= 100.0L)) result |= 1; } return result; }