aboutsummaryrefslogtreecommitdiff
path: root/tests/fenv_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/fenv_test.cpp')
-rw-r--r--tests/fenv_test.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/tests/fenv_test.cpp b/tests/fenv_test.cpp
index e983a1c08..89c7fd5c9 100644
--- a/tests/fenv_test.cpp
+++ b/tests/fenv_test.cpp
@@ -22,19 +22,20 @@
#include <stdint.h>
static void TestRounding(float expectation1, float expectation2) {
- // volatile to prevent compiler optimizations.
+ // Volatile to prevent compile-time evaluation.
volatile float f = 1.968750f;
volatile float m = 0x1.0p23f;
- volatile float x = f + m;
+ float x;
+ DoNotOptimize(x = f + m);
ASSERT_FLOAT_EQ(expectation1, x);
- x = x - m;
+ DoNotOptimize(x = x - m);
ASSERT_EQ(expectation2, x);
}
static void DivideByZero() {
- // volatile to prevent compiler optimizations.
+ // Volatile to prevent compile-time evaluation.
volatile float zero = 0.0f;
- volatile float result __attribute__((unused)) = 123.0f / zero;
+ DoNotOptimize(123.0f / zero);
}
TEST(fenv, fesetround_fegetround_FE_TONEAREST) {