Resolved uninitialized return value warnings #685

This commit is contained in:
Christophe Riccio 2017-10-22 15:31:47 +02:00
parent 7733266417
commit 25e7bef346

View File

@ -669,39 +669,20 @@ namespace detail
T biggestVal = sqrt(fourBiggestSquaredMinus1 + static_cast<T>(1)) * static_cast<T>(0.5);
T mult = static_cast<T>(0.25) / biggestVal;
tquat<T, Q> Result;
switch(biggestIndex)
{
case 0:
Result.w = biggestVal;
Result.x = (m[1][2] - m[2][1]) * mult;
Result.y = (m[2][0] - m[0][2]) * mult;
Result.z = (m[0][1] - m[1][0]) * mult;
break;
return tquat<T, Q>(biggestVal, (m[1][2] - m[2][1]) * mult, (m[2][0] - m[0][2]) * mult, (m[0][1] - m[1][0]) * mult);
case 1:
Result.w = (m[1][2] - m[2][1]) * mult;
Result.x = biggestVal;
Result.y = (m[0][1] + m[1][0]) * mult;
Result.z = (m[2][0] + m[0][2]) * mult;
break;
return tquat<T, Q>((m[1][2] - m[2][1]) * mult, biggestVal, (m[0][1] + m[1][0]) * mult, (m[2][0] + m[0][2]) * mult);
case 2:
Result.w = (m[2][0] - m[0][2]) * mult;
Result.x = (m[0][1] + m[1][0]) * mult;
Result.y = biggestVal;
Result.z = (m[1][2] + m[2][1]) * mult;
break;
return tquat<T, Q>((m[2][0] - m[0][2]) * mult, (m[0][1] + m[1][0]) * mult, biggestVal, (m[1][2] + m[2][1]) * mult);
case 3:
Result.w = (m[0][1] - m[1][0]) * mult;
Result.x = (m[2][0] + m[0][2]) * mult;
Result.y = (m[1][2] + m[2][1]) * mult;
Result.z = biggestVal;
break;
default: // Silence a -Wswitch-default warning in GCC. Should never actually get here. Assert is just for sanity.
return tquat<T, Q>((m[0][1] - m[1][0]) * mult, (m[2][0] + m[0][2]) * mult, (m[1][2] + m[2][1]) * mult, biggestVal);
default: // Silence a -Wswitch-default warning in GCC. Should never actually get here. Assert is just for sanity.
assert(false);
break;
return tquat<T, Q>(1, 0, 0, 0);
}
return Result;
}
template<typename T, qualifier Q>