From 78691fa76d40751173be95527ece8821113a1be0 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Sat, 20 Apr 2019 18:53:00 -0400 Subject: make new math code compatible with unused variable warning/error commit b50d315fd23f0fbc4c11e2583801dd123d933745 introduced fp_force_eval implemented by default with a dead store to a volatile variable. unfortunately introduces warnings with -Wunused-variable and breaks the ability to use -Werror with the default warning options set by configure when warnings are enabled. we could just call fp_barrier instead, but that results in a spurious load after the store due to volatile semantics. the fix committed here avoids the load. it will still produce warnings without -Wno-unused-but-set-variable, but that's part of our default warning profile, and there are already other locations in the source where an unused variable warning will occur without it. --- src/internal/libm.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/internal/libm.h') diff --git a/src/internal/libm.h b/src/internal/libm.h index 05f14e48..b5bd26b8 100644 --- a/src/internal/libm.h +++ b/src/internal/libm.h @@ -154,7 +154,8 @@ static inline long double fp_barrierl(long double x) #define fp_force_evalf fp_force_evalf static inline void fp_force_evalf(float x) { - volatile float y = x; + volatile float y; + y = x; } #endif @@ -162,7 +163,8 @@ static inline void fp_force_evalf(float x) #define fp_force_eval fp_force_eval static inline void fp_force_eval(double x) { - volatile double y = x; + volatile double y; + y = x; } #endif @@ -170,7 +172,8 @@ static inline void fp_force_eval(double x) #define fp_force_evall fp_force_evall static inline void fp_force_evall(long double x) { - volatile long double y = x; + volatile long double y; + y = x; } #endif -- cgit v1.2.1