From aec29a3a37fc0af78392151cf8adc1429c5934f3 Mon Sep 17 00:00:00 2001 From: Erik Hofman Date: Sun, 20 Nov 2016 23:54:15 +0100 Subject: [PATCH] Fix clang errors --- simgear/math/simd.hxx | 47 +++++++++++++++++++++--------------- simgear/math/test_sgvec4.cxx | 12 ++++++++- 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/simgear/math/simd.hxx b/simgear/math/simd.hxx index a4be37a4..ae2d62bb 100644 --- a/simgear/math/simd.hxx +++ b/simgear/math/simd.hxx @@ -307,7 +307,8 @@ public: } inline simd4_t& operator+=(float f) { - simd4 += f; + simd4_t r(f); + simd4 += r; return *this; } inline simd4_t& operator+=(const simd4_t& v) { @@ -316,7 +317,8 @@ public: } inline simd4_t& operator-=(float f) { - simd4 -= f; + simd4_t r(f); + simd4 -= r; return *this; } inline simd4_t& operator-=(const simd4_t& v) { @@ -325,7 +327,8 @@ public: } inline simd4_t& operator *=(float f) { - simd4 *= f; + simd4_t r(f); + simd4 *= r.simd4; return *this; } inline simd4_t& operator*=(const simd4_t& v) { @@ -334,8 +337,8 @@ public: } inline simd4_t& operator/=(float f) { - f = (1.0f/f); - simd4 *= f; + simd4_t r(1.0f/f); + simd4 *= r.simd4; return *this; } inline simd4_t& operator/=(const simd4_t& v) { @@ -412,8 +415,9 @@ public: } inline simd4_t& operator+=(double d) { - simd4[0] += d; - simd4[1] += d; + simd4_t r(d); + simd4[0] += r; + simd4[1] += r; return *this; } inline simd4_t& operator+=(const simd4_t& v) { @@ -423,8 +427,9 @@ public: } inline simd4_t& operator-=(double d) { - simd4[0] -= d; - simd4[1] -= d; + simd4_t r(d); + simd4[0] -= r; + simd4[1] -= r; return *this; } inline simd4_t& operator-=(const simd4_t& v) { @@ -434,8 +439,9 @@ public: } inline simd4_t& operator *=(double d) { - simd4[0] *= d; - simd4[1] *= d; + simd4_t r(d); + simd4[0] *= r; + simd4[1] *= r; return *this; } inline simd4_t& operator*=(const simd4_t& v) { @@ -445,9 +451,9 @@ public: } inline simd4_t& operator/=(double d) { - d = (1.0/d); - simd4[0] *= d; - simd4[1] *= d; + simd4_t r(1.0/d); + simd4[0] *= r; + simd4[1] *= r; return *this; } inline simd4_t& operator/=(const simd4_t& v) { @@ -515,7 +521,8 @@ public: } inline simd4_t& operator+=(int i) { - simd4 += i; + simd4_t r(i); + simd4 += r; return *this; } inline simd4_t& operator+=(const simd4_t& v) { @@ -524,7 +531,8 @@ public: } inline simd4_t& operator-=(int i) { - simd4 -= i; + simd4_t r(i); + simd4 -= r; return *this; } inline simd4_t& operator-=(const simd4_t& v) { @@ -533,7 +541,8 @@ public: } inline simd4_t& operator *=(int i) { - simd4 *= i; + simd4_t r(i); + simd4 *= r; return *this; } inline simd4_t& operator*=(const simd4_t& v) { @@ -542,8 +551,8 @@ public: } inline simd4_t& operator/=(int i) { - i = (1/i); - simd4 *= i; + simd4_t r(i); + simd4 /= r; return *this; } inline simd4_t& operator/=(const simd4_t& v) { diff --git a/simgear/math/test_sgvec4.cxx b/simgear/math/test_sgvec4.cxx index 2a089b3b..0ae13f82 100644 --- a/simgear/math/test_sgvec4.cxx +++ b/simgear/math/test_sgvec4.cxx @@ -3,7 +3,6 @@ #include #include -#include "SGVec3.hxx" #include "SGVec4.hxx" // set to 0 for a timing test @@ -26,6 +25,7 @@ int main() { T p[4] = { 1.03, 0.55, 0.707, -0.01 }; const SGVec4 q( 0.31, 0.43, 0.69, 1.0 ); + float res = 0.0f; long int i; for (i=0; i t = x - y; f = dot(v, v); g = (t[0]*t[0] + t[1]*t[1] + t[2]*t[2] + t[3]*t[3]); +#if TEST_ACCURACY if (f != g) { printf("line: %i: dot: f: %5.4f, g: %5.4f\n", __LINE__, f, g); } +#endif + + res += f; } + + printf("res: %f\n", res); }