Michael Goffioul wrote: > With the #pragma statement, the compilation error disappears, thanks.
Thanks for verifying that we were on the right track. > I think the same > problem will appear in round.c and trunc.c (those are also used by > octave). Yes, and there are a few more. I'm applying this patch. 2012-02-28 Bruno Haible <br...@clisp.org> Avoid compilation errors with MSVC option -fp:strict. * lib/floor.c: Use MSVC specific pragma fenv_access. * lib/ceil.c: Likewise. * lib/trunc.c: Likewise. * lib/round.c: Likewise. * lib/rint.c: Likewise. * lib/fma.c: Likewise. * lib/integer_length.c: Likewise. * m4/round.m4 (gl_FUNC_ROUND): Likewise. * m4/roundf.m4 (gl_FUNC_ROUNDF): Likewise. * tests/test-floor2.c: Likewise. * tests/test-floorf2.c: Likewise. * tests/test-ceil2.c: Likewise. * tests/test-ceilf2.c: Likewise. * tests/test-trunc2.c: Likewise. * tests/test-truncf2.c: Likewise. Reported by Michael Goffioul <michael.goffi...@gmail.com>. --- lib/ceil.c.orig Tue Feb 28 11:49:10 2012 +++ lib/ceil.c Tue Feb 28 03:03:43 2012 @@ -54,6 +54,12 @@ # define MINUS_ZERO L_(-0.0) #endif +/* MSVC with option -fp:strict refuses to compile constant initializers that + contain floating-point operations. Pacify this compiler. */ +#ifdef _MSC_VER +# pragma fenv_access (off) +#endif + /* 2^(MANT_DIG-1). */ static const DOUBLE TWO_MANT_DIG = /* Assume MANT_DIG <= 5 * 31. --- lib/floor.c.orig Tue Feb 28 11:49:10 2012 +++ lib/floor.c Tue Feb 28 03:03:43 2012 @@ -42,6 +42,12 @@ # define L_(literal) literal##f #endif +/* MSVC with option -fp:strict refuses to compile constant initializers that + contain floating-point operations. Pacify this compiler. */ +#ifdef _MSC_VER +# pragma fenv_access (off) +#endif + /* 2^(MANT_DIG-1). */ static const DOUBLE TWO_MANT_DIG = /* Assume MANT_DIG <= 5 * 31. --- lib/fma.c.orig Tue Feb 28 11:49:10 2012 +++ lib/fma.c Tue Feb 28 03:01:11 2012 @@ -66,6 +66,12 @@ #undef MIN #define MIN(a,b) ((a) < (b) ? (a) : (b)) +/* MSVC with option -fp:strict refuses to compile constant initializers that + contain floating-point operations. Pacify this compiler. */ +#ifdef _MSC_VER +# pragma fenv_access (off) +#endif + /* It is possible to write an implementation of fused multiply-add with floating-point operations alone. See Sylvie Boldo, Guillaume Melquiond: --- lib/integer_length.c.orig Tue Feb 28 11:49:10 2012 +++ lib/integer_length.c Tue Feb 28 03:03:44 2012 @@ -25,6 +25,12 @@ #include "float+.h" +/* MSVC with option -fp:strict refuses to compile constant initializers that + contain floating-point operations. Pacify this compiler. */ +#ifdef _MSC_VER +# pragma fenv_access (off) +#endif + #define NBITS (sizeof (unsigned int) * CHAR_BIT) int --- lib/rint.c.orig Tue Feb 28 11:49:10 2012 +++ lib/rint.c Tue Feb 28 03:03:44 2012 @@ -53,6 +53,12 @@ # define MINUS_ZERO L_(-0.0) #endif +/* MSVC with option -fp:strict refuses to compile constant initializers that + contain floating-point operations. Pacify this compiler. */ +#ifdef _MSC_VER +# pragma fenv_access (off) +#endif + DOUBLE RINT (DOUBLE x) { --- lib/round.c.orig Tue Feb 28 11:49:10 2012 +++ lib/round.c Tue Feb 28 03:03:43 2012 @@ -64,6 +64,12 @@ # define MINUS_ZERO L_(-0.0) #endif +/* MSVC with option -fp:strict refuses to compile constant initializers that + contain floating-point operations. Pacify this compiler. */ +#ifdef _MSC_VER +# pragma fenv_access (off) +#endif + /* If we're being included from test-round2[f].c, it already defined names for our round implementations. Otherwise, pick the preferred implementation for this machine. */ --- lib/trunc.c.orig Tue Feb 28 11:49:10 2012 +++ lib/trunc.c Tue Feb 28 11:47:41 2012 @@ -54,6 +54,12 @@ # define MINUS_ZERO L_(-0.0) #endif +/* MSVC with option -fp:strict refuses to compile constant initializers that + contain floating-point operations. Pacify this compiler. */ +#ifdef _MSC_VER +# pragma fenv_access (off) +#endif + /* 2^(MANT_DIG-1). */ static const DOUBLE TWO_MANT_DIG = /* Assume MANT_DIG <= 5 * 31. --- m4/round.m4.orig Tue Feb 28 11:49:10 2012 +++ m4/round.m4 Tue Feb 28 03:45:00 2012 @@ -1,4 +1,4 @@ -# round.m4 serial 13 +# round.m4 serial 14 dnl Copyright (C) 2007, 2009-2012 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -25,6 +25,9 @@ AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <float.h> #include <math.h> +#ifdef _MSC_VER +# pragma fenv_access (off) +#endif int main() { /* 2^DBL_MANT_DIG. */ --- m4/roundf.m4.orig Tue Feb 28 11:49:10 2012 +++ m4/roundf.m4 Tue Feb 28 03:45:00 2012 @@ -1,4 +1,4 @@ -# roundf.m4 serial 14 +# roundf.m4 serial 15 dnl Copyright (C) 2007-2012 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -25,6 +25,9 @@ AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <float.h> #include <math.h> +#ifdef _MSC_VER +# pragma fenv_access (off) +#endif int main() { /* 2^FLT_MANT_DIG. */ --- tests/test-ceil2.c.orig Tue Feb 28 11:49:10 2012 +++ tests/test-ceil2.c Tue Feb 28 03:04:42 2012 @@ -32,6 +32,12 @@ #include "minus-zero.h" #include "macros.h" +/* MSVC with option -fp:strict refuses to compile constant initializers that + contain floating-point operations. Pacify this compiler. */ +#ifdef _MSC_VER +# pragma fenv_access (off) +#endif + /* The reference implementation, taken from lib/ceil.c. */ --- tests/test-ceilf2.c.orig Tue Feb 28 11:49:10 2012 +++ tests/test-ceilf2.c Tue Feb 28 03:04:42 2012 @@ -32,6 +32,12 @@ #include "minus-zero.h" #include "macros.h" +/* MSVC with option -fp:strict refuses to compile constant initializers that + contain floating-point operations. Pacify this compiler. */ +#ifdef _MSC_VER +# pragma fenv_access (off) +#endif + /* The reference implementation, taken from lib/ceil.c. */ --- tests/test-floor2.c.orig Tue Feb 28 11:49:10 2012 +++ tests/test-floor2.c Tue Feb 28 03:05:12 2012 @@ -31,6 +31,12 @@ #include "isnand-nolibm.h" #include "macros.h" +/* MSVC with option -fp:strict refuses to compile constant initializers that + contain floating-point operations. Pacify this compiler. */ +#ifdef _MSC_VER +# pragma fenv_access (off) +#endif + /* The reference implementation, taken from lib/floor.c. */ --- tests/test-floorf2.c.orig Tue Feb 28 11:49:10 2012 +++ tests/test-floorf2.c Tue Feb 28 03:05:13 2012 @@ -31,6 +31,12 @@ #include "isnanf-nolibm.h" #include "macros.h" +/* MSVC with option -fp:strict refuses to compile constant initializers that + contain floating-point operations. Pacify this compiler. */ +#ifdef _MSC_VER +# pragma fenv_access (off) +#endif + /* The reference implementation, taken from lib/floor.c. */ --- tests/test-trunc2.c.orig Tue Feb 28 11:49:10 2012 +++ tests/test-trunc2.c Tue Feb 28 03:06:16 2012 @@ -32,6 +32,12 @@ #include "minus-zero.h" #include "macros.h" +/* MSVC with option -fp:strict refuses to compile constant initializers that + contain floating-point operations. Pacify this compiler. */ +#ifdef _MSC_VER +# pragma fenv_access (off) +#endif + /* The reference implementation, taken from lib/trunc.c. */ --- tests/test-truncf2.c.orig Tue Feb 28 11:49:10 2012 +++ tests/test-truncf2.c Tue Feb 28 03:06:16 2012 @@ -32,6 +32,12 @@ #include "minus-zero.h" #include "macros.h" +/* MSVC with option -fp:strict refuses to compile constant initializers that + contain floating-point operations. Pacify this compiler. */ +#ifdef _MSC_VER +# pragma fenv_access (off) +#endif + /* The reference implementation, taken from lib/trunc.c. */