diff options
author | Gary E. Miller <gem@rellim.com> | 2015-04-01 14:34:33 -0700 |
---|---|---|
committer | Gary E. Miller <gem@rellim.com> | 2015-04-01 14:34:33 -0700 |
commit | bf06d7060901832c51895ecd19c2e3fe6f9bd27f (patch) | |
tree | eea02e7daa1dc9a66fefccb035742b39d8ac987c /test_float.c | |
parent | 36e64159a1e85a11044c42172292a91750526ecf (diff) | |
download | gpsd-bf06d7060901832c51895ecd19c2e3fe6f9bd27f.tar.gz |
cppcheck found gcc optimizing away a float test.
Diffstat (limited to 'test_float.c')
-rw-r--r-- | test_float.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/test_float.c b/test_float.c index 6227bc8f..cc99d4a1 100644 --- a/test_float.c +++ b/test_float.c @@ -269,17 +269,27 @@ int test_double(void) { int test_modulo(void) { static int e = 0; - if (-5 % 2 != -1) { + /* make sure that gcc does not optimize these away */ + volatile int a; + volatile int b; + + a = -5; + b = 2; + if (a % b != -1) { printf("m1 "); e++; } - if (-5 % -2 != -1) { + a = -5; + b = -2; + if (a % b != -1) { printf("m2 "); e++; } - if (5 % -2 != 1) { + a = 5; + b = -2; + if (a % b != 1) { printf("m3 "); e++; } |