From 8e742a4d07621e9502f176116b31a2d07b8d8a54 Mon Sep 17 00:00:00 2001 From: Collin Baker Date: Tue, 21 Jul 2015 23:02:30 -0400 Subject: [PATCH] Fixed intermittent segfault in test-gtx_fast_trigonometry.cpp The fastAbs() function was accessing its argument as if it were a vec4 but it was being called with a float. Also, it relied onundefined behavior. I replaced it with glm::abs(). --- test/gtx/gtx_fast_trigonometry.cpp | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/test/gtx/gtx_fast_trigonometry.cpp b/test/gtx/gtx_fast_trigonometry.cpp index 46faffd5..08793d43 100644 --- a/test/gtx/gtx_fast_trigonometry.cpp +++ b/test/gtx/gtx_fast_trigonometry.cpp @@ -233,21 +233,10 @@ namespace taylorCos - Powed6 * static_cast(0.00138888888888888888888888888889); } - template class vecType> - GLM_FUNC_QUALIFIER vecType fastAbs(vecType x) - { - int* Pointer = reinterpret_cast(&x[0]); - *(((int *) &Pointer[0]) + 1) &= 0x7fffffff; - *(((int *) &Pointer[1]) + 1) &= 0x7fffffff; - *(((int *) &Pointer[2]) + 1) &= 0x7fffffff; - *(((int *) &Pointer[3]) + 1) &= 0x7fffffff; - return x; - } - template class vecType> GLM_FUNC_QUALIFIER vecType fastCosNew(vecType const & x) { - vecType const Angle0_PI(fastAbs(fmod(x + glm::pi(), glm::two_pi()) - glm::pi())); + vecType const Angle0_PI(glm::abs(fmod(x + glm::pi(), glm::two_pi()) - glm::pi())); return taylorSeriesNewCos6(x); /* vecType const FirstQuarterPi(lessThanEqual(Angle0_PI, vecType(glm::half_pi())));