From 7464eef7a1c742ae24500d2813967780c25f5787 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 14 Sep 2022 07:15:53 -0700 Subject: nan-boxing: use GCC pragmas to disable aliasing warnings. * arith.c (flo): The line of code which triggers the aliasing diagnostic is wrapped with GNU-C-specific pramgas that disable the diagnostic just for that line. * lib.h (c_f): Likewise. * configure: Drop the test which adds -Wno-strict-aliasing to the DIAG_FLAGS; --- arith.c | 7 +++++++ configure | 18 ------------------ lib.h | 7 +++++++ 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/arith.c b/arith.c index 30847a4a..d135e2a4 100644 --- a/arith.c +++ b/arith.c @@ -4274,7 +4274,14 @@ val flo(double n) uw_throw(numeric_error_s, lit("out-of-range floating-point result")); } else { #if CONFIG_NAN_BOXING +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif ucnum u = *(ucnum *) &n + NAN_FLNUM_DELTA; +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif return coerce(val, u); #else val obj = make_obj(); diff --git a/configure b/configure index 01ac4531..51c11fa8 100755 --- a/configure +++ b/configure @@ -1603,24 +1603,6 @@ if [ -n "$nan_boxing" ] ; then fi fi -if [ -n "$nan_boxing" ] ; then - printf "Checking how to disable strict aliasing warnings ... " - - cat > conftest.c < conftest.c < diff --git a/lib.h b/lib.h index 35a237fa..c2f42408 100644 --- a/lib.h +++ b/lib.h @@ -625,7 +625,14 @@ INLINE double c_f(val num) { #if CONFIG_NAN_BOXING ucnum u = coerce(ucnum, num) - NAN_FLNUM_DELTA; +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif return *coerce(double *, &u); +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif #else return num->fl.n; #endif -- cgit v1.2.3