Browse Source

Math: expect NoInit test failures on GCC 6.1+ with optimizations enabled.

It's nothing harmful, just inefficient.
pull/187/head^2
Vladimír Vondruš 10 years ago
parent
commit
e9a2623e02
  1. 17
      src/Magnum/Math/Test/AngleTest.cpp
  2. 7
      src/Magnum/Math/Test/BezierTest.cpp
  3. 7
      src/Magnum/Math/Test/BoolVectorTest.cpp
  4. 9
      src/Magnum/Math/Test/ColorTest.cpp
  5. 7
      src/Magnum/Math/Test/ComplexTest.cpp
  6. 7
      src/Magnum/Math/Test/DualComplexTest.cpp
  7. 7
      src/Magnum/Math/Test/DualQuaternionTest.cpp
  8. 9
      src/Magnum/Math/Test/DualTest.cpp
  9. 11
      src/Magnum/Math/Test/Matrix3Test.cpp
  10. 13
      src/Magnum/Math/Test/Matrix4Test.cpp
  11. 13
      src/Magnum/Math/Test/MatrixTest.cpp
  12. 7
      src/Magnum/Math/Test/QuaternionTest.cpp
  13. 11
      src/Magnum/Math/Test/RangeTest.cpp
  14. 11
      src/Magnum/Math/Test/RectangularMatrixTest.cpp
  15. 7
      src/Magnum/Math/Test/UnitTest.cpp
  16. 7
      src/Magnum/Math/Test/Vector2Test.cpp
  17. 7
      src/Magnum/Math/Test/Vector3Test.cpp
  18. 7
      src/Magnum/Math/Test/Vector4Test.cpp
  19. 7
      src/Magnum/Math/Test/VectorTest.cpp

17
src/Magnum/Math/Test/AngleTest.cpp

@ -105,8 +105,21 @@ void AngleTest::constructNoInit() {
Rad b{3.14f};
new(&a) Deg{NoInit};
new(&b) Rad{NoInit};
CORRADE_COMPARE(Float(a), 25.0f);
CORRADE_COMPARE(Float(b), 3.14f);
{
#if defined(__GNUC__) && __GNUC__*100 + __GNUC_MINOR__ >= 601
/* The warning is reported for both debug and release build */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#ifdef __OPTIMIZE__
CORRADE_EXPECT_FAIL("GCC 6.1+ misoptimizes and overwrites the value.");
#endif
#endif
CORRADE_COMPARE(Float(a), 25.0f);
CORRADE_COMPARE(Float(b), 3.14f);
#if defined(__GNUC__) && __GNUC__*100 + __GNUC_MINOR__ >= 601
#pragma GCC diagnostic pop
#endif
}
CORRADE_VERIFY((std::is_nothrow_constructible<Deg, NoInitT>::value));
CORRADE_VERIFY((std::is_nothrow_constructible<Rad, NoInitT>::value));

7
src/Magnum/Math/Test/BezierTest.cpp

@ -108,7 +108,12 @@ void BezierTest::constructDefault() {
void BezierTest::constructNoInit() {
QuadraticBezier2D a{Vector2{0.5f, 1.0f}, Vector2{1.1f, 0.3f}, Vector2{0.1f, 1.2f}};
new(&a) QuadraticBezier2D{NoInit};
CORRADE_COMPARE(a, (QuadraticBezier2D{Vector2{0.5f, 1.0f}, Vector2{1.1f, 0.3f}, Vector2{0.1f, 1.2f}}));
{
#if defined(__GNUC__) && __GNUC__*100 + __GNUC_MINOR__ >= 601 && __OPTIMIZE__
CORRADE_EXPECT_FAIL("GCC 6.1+ misoptimizes and overwrites the value.");
#endif
CORRADE_COMPARE(a, (QuadraticBezier2D{Vector2{0.5f, 1.0f}, Vector2{1.1f, 0.3f}, Vector2{0.1f, 1.2f}}));
}
CORRADE_VERIFY((std::is_nothrow_constructible<QuadraticBezier2D, NoInitT>::value));
}

7
src/Magnum/Math/Test/BoolVectorTest.cpp

@ -100,7 +100,12 @@ void BoolVectorTest::constructDefault() {
void BoolVectorTest::constructNoInit() {
BoolVector19 a{0xa5, 0x5f, 0x07};
new(&a) BoolVector19{NoInit};
CORRADE_COMPARE(a, BoolVector19(0xa5, 0x5f, 0x07));
{
#if defined(__GNUC__) && __GNUC__*100 + __GNUC_MINOR__ >= 601 && __OPTIMIZE__
CORRADE_EXPECT_FAIL("GCC 6.1+ misoptimizes and overwrites the value.");
#endif
CORRADE_COMPARE(a, BoolVector19(0xa5, 0x5f, 0x07));
}
CORRADE_VERIFY((std::is_nothrow_constructible<BoolVector19, NoInitT>::value));
}

9
src/Magnum/Math/Test/ColorTest.cpp

@ -185,8 +185,13 @@ void ColorTest::constructNoInit() {
Color4 b{1.0f, 0.5f, 0.75f, 0.5f};
new(&a) Color3{Math::NoInit};
new(&b) Color4{Math::NoInit};
CORRADE_COMPARE(a, (Color3{1.0f, 0.5f, 0.75f}));
CORRADE_COMPARE(b, (Color4{1.0f, 0.5f, 0.75f, 0.5f}));
{
#if defined(__GNUC__) && __GNUC__*100 + __GNUC_MINOR__ >= 601 && __OPTIMIZE__
CORRADE_EXPECT_FAIL("GCC 6.1+ misoptimizes and overwrites the value.");
#endif
CORRADE_COMPARE(a, (Color3{1.0f, 0.5f, 0.75f}));
CORRADE_COMPARE(b, (Color4{1.0f, 0.5f, 0.75f, 0.5f}));
}
CORRADE_VERIFY((std::is_nothrow_constructible<Color3, NoInitT>::value));
CORRADE_VERIFY((std::is_nothrow_constructible<Color4, NoInitT>::value));

7
src/Magnum/Math/Test/ComplexTest.cpp

@ -175,7 +175,12 @@ void ComplexTest::constructZero() {
void ComplexTest::constructNoInit() {
Complex a{0.5f, -3.7f};
new(&a) Complex{NoInit};
CORRADE_COMPARE(a, Complex(0.5f, -3.7f));
{
#if defined(__GNUC__) && __GNUC__*100 + __GNUC_MINOR__ >= 601 && __OPTIMIZE__
CORRADE_EXPECT_FAIL("GCC 6.1+ misoptimizes and overwrites the value.");
#endif
CORRADE_COMPARE(a, Complex(0.5f, -3.7f));
}
CORRADE_VERIFY((std::is_nothrow_constructible<Complex, NoInitT>::value));
}

7
src/Magnum/Math/Test/DualComplexTest.cpp

@ -178,7 +178,12 @@ void DualComplexTest::constructZero() {
void DualComplexTest::constructNoInit() {
DualComplex a{{-1.0f, 2.5f}, {3.0f, -7.5f}};
new(&a) DualComplex{NoInit};
CORRADE_COMPARE(a, DualComplex({-1.0f, 2.5f}, {3.0f, -7.5f}));
{
#if defined(__GNUC__) && __GNUC__*100 + __GNUC_MINOR__ >= 601 && __OPTIMIZE__
CORRADE_EXPECT_FAIL("GCC 6.1+ misoptimizes and overwrites the value.");
#endif
CORRADE_COMPARE(a, DualComplex({-1.0f, 2.5f}, {3.0f, -7.5f}));
}
CORRADE_VERIFY((std::is_nothrow_constructible<DualComplex, NoInitT>::value));
}

7
src/Magnum/Math/Test/DualQuaternionTest.cpp

@ -200,7 +200,12 @@ void DualQuaternionTest::constructZero() {
void DualQuaternionTest::constructNoInit() {
DualQuaternion a{{{1.0f, 2.0f, 3.0f}, -4.0f}, {{0.5f, -3.1f, 3.3f}, 2.0f}};
new(&a) DualQuaternion{NoInit};
CORRADE_COMPARE(a, DualQuaternion({{1.0f, 2.0f, 3.0f}, -4.0f}, {{0.5f, -3.1f, 3.3f}, 2.0f}));
{
#if defined(__GNUC__) && __GNUC__*100 + __GNUC_MINOR__ >= 601 && __OPTIMIZE__
CORRADE_EXPECT_FAIL("GCC 6.1+ misoptimizes and overwrites the value.");
#endif
CORRADE_COMPARE(a, DualQuaternion({{1.0f, 2.0f, 3.0f}, -4.0f}, {{0.5f, -3.1f, 3.3f}, 2.0f}));
}
CORRADE_VERIFY((std::is_nothrow_constructible<DualQuaternion, NoInitT>::value));
}

9
src/Magnum/Math/Test/DualTest.cpp

@ -137,8 +137,13 @@ void DualTest::constructNoInit() {
Math::Dual<Math::Quaternion<Float>> b{{{3.0f, 0.1f, 1.0f}, 1.0f}, {{0.1f, 0.0f, 1.0f}, 0.3f}};
new(&a) Dual{NoInit};
new(&b) Math::Dual<Math::Quaternion<Float>>{NoInit};
CORRADE_COMPARE(a, Dual(2.0f, -7.5f));
CORRADE_COMPARE(b, (Math::Dual<Math::Quaternion<Float>>{{{3.0f, 0.1f, 1.0f}, 1.0f}, {{0.1f, 0.0f, 1.0f}, 0.3f}}));
{
#if defined(__GNUC__) && __GNUC__*100 + __GNUC_MINOR__ >= 601 && __OPTIMIZE__
CORRADE_EXPECT_FAIL("GCC 6.1+ misoptimizes and overwrites the value.");
#endif
CORRADE_COMPARE(a, Dual(2.0f, -7.5f));
CORRADE_COMPARE(b, (Math::Dual<Math::Quaternion<Float>>{{{3.0f, 0.1f, 1.0f}, 1.0f}, {{0.1f, 0.0f, 1.0f}, 0.3f}}));
}
CORRADE_VERIFY((std::is_nothrow_constructible<Dual, NoInitT>::value));
CORRADE_VERIFY((std::is_nothrow_constructible<Math::Dual<Math::Quaternion<Float>>, NoInitT>::value));

11
src/Magnum/Math/Test/Matrix3Test.cpp

@ -175,9 +175,14 @@ void Matrix3Test::constructNoInit() {
{4.5f, 4.0f, 7.0f},
{7.9f, -1.0f, 8.0f}};
new(&a) Matrix3{NoInit};
CORRADE_COMPARE(a, Matrix3({3.0f, 5.0f, 8.0f},
{4.5f, 4.0f, 7.0f},
{7.9f, -1.0f, 8.0f}));
{
#if defined(__GNUC__) && __GNUC__*100 + __GNUC_MINOR__ >= 601 && __OPTIMIZE__
CORRADE_EXPECT_FAIL("GCC 6.1+ misoptimizes and overwrites the value.");
#endif
CORRADE_COMPARE(a, Matrix3({3.0f, 5.0f, 8.0f},
{4.5f, 4.0f, 7.0f},
{7.9f, -1.0f, 8.0f}));
}
CORRADE_VERIFY((std::is_nothrow_constructible<Matrix3, NoInitT>::value));
}

13
src/Magnum/Math/Test/Matrix4Test.cpp

@ -207,10 +207,15 @@ void Matrix4Test::constructNoInit() {
{1.0f, 2.0f, 3.0f, -1.0f},
{7.9f, -1.0f, 8.0f, -1.5f}};
new(&a) Matrix4{NoInit};
CORRADE_COMPARE(a, Matrix4({3.0f, 5.0f, 8.0f, -3.0f},
{4.5f, 4.0f, 7.0f, 2.0f},
{1.0f, 2.0f, 3.0f, -1.0f},
{7.9f, -1.0f, 8.0f, -1.5f}));
{
#if defined(__GNUC__) && __GNUC__*100 + __GNUC_MINOR__ >= 601 && __OPTIMIZE__
CORRADE_EXPECT_FAIL("GCC 6.1+ misoptimizes and overwrites the value.");
#endif
CORRADE_COMPARE(a, Matrix4({3.0f, 5.0f, 8.0f, -3.0f},
{4.5f, 4.0f, 7.0f, 2.0f},
{1.0f, 2.0f, 3.0f, -1.0f},
{7.9f, -1.0f, 8.0f, -1.5f}));
}
CORRADE_VERIFY((std::is_nothrow_constructible<Matrix4, NoInitT>::value));
}

13
src/Magnum/Math/Test/MatrixTest.cpp

@ -166,10 +166,15 @@ void MatrixTest::constructNoInit() {
Vector4(1.0f, 2.0f, 3.0f, -1.0f),
Vector4(7.9f, -1.0f, 8.0f, -1.5f)};
new(&a) Matrix4x4{NoInit};
CORRADE_COMPARE(a, Matrix4x4(Vector4(3.0f, 5.0f, 8.0f, -3.0f),
Vector4(4.5f, 4.0f, 7.0f, 2.0f),
Vector4(1.0f, 2.0f, 3.0f, -1.0f),
Vector4(7.9f, -1.0f, 8.0f, -1.5f)));
{
#if defined(__GNUC__) && __GNUC__*100 + __GNUC_MINOR__ >= 601 && __OPTIMIZE__
CORRADE_EXPECT_FAIL("GCC 6.1+ misoptimizes and overwrites the value.");
#endif
CORRADE_COMPARE(a, Matrix4x4(Vector4(3.0f, 5.0f, 8.0f, -3.0f),
Vector4(4.5f, 4.0f, 7.0f, 2.0f),
Vector4(1.0f, 2.0f, 3.0f, -1.0f),
Vector4(7.9f, -1.0f, 8.0f, -1.5f)));
}
CORRADE_VERIFY((std::is_nothrow_constructible<Matrix4x4, NoInitT>::value));
}

7
src/Magnum/Math/Test/QuaternionTest.cpp

@ -182,7 +182,12 @@ void QuaternionTest::constructZero() {
void QuaternionTest::constructNoInit() {
Quaternion a{{1.0f, 2.0f, 3.0f}, -4.0f};
new(&a) Quaternion{NoInit};
CORRADE_COMPARE(a, Quaternion({1.0f, 2.0f, 3.0f}, -4.0f));
{
#if defined(__GNUC__) && __GNUC__*100 + __GNUC_MINOR__ >= 601 && __OPTIMIZE__
CORRADE_EXPECT_FAIL("GCC 6.1+ misoptimizes and overwrites the value.");
#endif
CORRADE_COMPARE(a, Quaternion({1.0f, 2.0f, 3.0f}, -4.0f));
}
CORRADE_VERIFY((std::is_nothrow_constructible<Quaternion, NoInitT>::value));
}

11
src/Magnum/Math/Test/RangeTest.cpp

@ -216,9 +216,14 @@ void RangeTest::constructNoInit() {
new(&b) Range2Di{NoInit};
new(&c) Range3Di{NoInit};
CORRADE_COMPARE(a, (Range1Di{3, 23}));
CORRADE_COMPARE(b, (Range2Di{{3, 5}, {23, 78}}));
CORRADE_COMPARE(c, (Range3Di{{3, 5, -7}, {23, 78, 2}}));
{
#if defined(__GNUC__) && __GNUC__*100 + __GNUC_MINOR__ >= 601 && __OPTIMIZE__
CORRADE_EXPECT_FAIL("GCC 6.1+ misoptimizes and overwrites the value.");
#endif
CORRADE_COMPARE(a, (Range1Di{3, 23}));
CORRADE_COMPARE(b, (Range2Di{{3, 5}, {23, 78}}));
CORRADE_COMPARE(c, (Range3Di{{3, 5, -7}, {23, 78, 2}}));
}
CORRADE_VERIFY((std::is_nothrow_constructible<Range1Di, NoInitT>::value));
CORRADE_VERIFY((std::is_nothrow_constructible<Range2Di, NoInitT>::value));

11
src/Magnum/Math/Test/RectangularMatrixTest.cpp

@ -175,9 +175,14 @@ void RectangularMatrixTest::constructNoInit() {
Vector4(5.0f, 6.0f, 7.0f, 8.0f),
Vector4(9.0f, 10.0f, 11.0f, 12.0f)};
new(&a) Matrix3x4{NoInit};
CORRADE_COMPARE(a, Matrix3x4(Vector4(1.0f, 2.0f, 3.0f, 4.0f),
Vector4(5.0f, 6.0f, 7.0f, 8.0f),
Vector4(9.0f, 10.0f, 11.0f, 12.0f)));
{
#if defined(__GNUC__) && __GNUC__*100 + __GNUC_MINOR__ >= 601 && __OPTIMIZE__
CORRADE_EXPECT_FAIL("GCC 6.1+ misoptimizes and overwrites the value.");
#endif
CORRADE_COMPARE(a, Matrix3x4(Vector4(1.0f, 2.0f, 3.0f, 4.0f),
Vector4(5.0f, 6.0f, 7.0f, 8.0f),
Vector4(9.0f, 10.0f, 11.0f, 12.0f)));
}
CORRADE_VERIFY((std::is_nothrow_constructible<Matrix3x4, NoInitT>::value));
}

7
src/Magnum/Math/Test/UnitTest.cpp

@ -91,7 +91,12 @@ void UnitTest::constructDefault() {
void UnitTest::constructNoInit() {
Sec a{25.0f};
new(&a) Sec{NoInit};
CORRADE_COMPARE(a, Sec{25.0f});
{
#if defined(__GNUC__) && __GNUC__*100 + __GNUC_MINOR__ >= 601 && __OPTIMIZE__
CORRADE_EXPECT_FAIL("GCC 6.1+ misoptimizes and overwrites the value.");
#endif
CORRADE_COMPARE(a, Sec{25.0f});
}
CORRADE_VERIFY((std::is_nothrow_constructible<Sec, NoInitT>::value));
}

7
src/Magnum/Math/Test/Vector2Test.cpp

@ -121,7 +121,12 @@ void Vector2Test::constructDefault() {
void Vector2Test::constructNoInit() {
Vector2 a{1.5f, 2.5f};
new(&a) Vector2{NoInit};
CORRADE_COMPARE(a, (Vector2{1.5f, 2.5f}));
{
#if defined(__GNUC__) && __GNUC__*100 + __GNUC_MINOR__ >= 601 && __OPTIMIZE__
CORRADE_EXPECT_FAIL("GCC 6.1+ misoptimizes and overwrites the value.");
#endif
CORRADE_COMPARE(a, (Vector2{1.5f, 2.5f}));
}
CORRADE_VERIFY((std::is_nothrow_constructible<Vector2, NoInitT>::value));
}

7
src/Magnum/Math/Test/Vector3Test.cpp

@ -119,7 +119,12 @@ void Vector3Test::constructDefault() {
void Vector3Test::constructNoInit() {
Vector3 a{1.0f, 2.5f, -3.0f};
new(&a) Vector3{NoInit};
CORRADE_COMPARE(a, (Vector3{1.0f, 2.5f, -3.0f}));
{
#if defined(__GNUC__) && __GNUC__*100 + __GNUC_MINOR__ >= 601 && __OPTIMIZE__
CORRADE_EXPECT_FAIL("GCC 6.1+ misoptimizes and overwrites the value.");
#endif
CORRADE_COMPARE(a, (Vector3{1.0f, 2.5f, -3.0f}));
}
CORRADE_VERIFY((std::is_nothrow_constructible<Vector3, NoInitT>::value));
}

7
src/Magnum/Math/Test/Vector4Test.cpp

@ -134,7 +134,12 @@ void Vector4Test::constructDefault() {
void Vector4Test::constructNoInit() {
Vector4 a{1.0f, -2.5f, 3.0f, 4.1f};
new(&a) Vector4{NoInit};
CORRADE_COMPARE(a, (Vector4{1.0f, -2.5f, 3.0f, 4.1f}));
{
#if defined(__GNUC__) && __GNUC__*100 + __GNUC_MINOR__ >= 601 && __OPTIMIZE__
CORRADE_EXPECT_FAIL("GCC 6.1+ misoptimizes and overwrites the value.");
#endif
CORRADE_COMPARE(a, (Vector4{1.0f, -2.5f, 3.0f, 4.1f}));
}
CORRADE_VERIFY((std::is_nothrow_constructible<Vector4, NoInitT>::value));
}

7
src/Magnum/Math/Test/VectorTest.cpp

@ -208,7 +208,12 @@ void VectorTest::constructDefault() {
void VectorTest::constructNoInit() {
Vector4 a{1.0f, 2.0f, -3.0f, 4.5f};
new(&a) Vector4{NoInit};
CORRADE_COMPARE(a, (Vector4{1.0f, 2.0f, -3.0f, 4.5f}));
{
#if defined(__GNUC__) && __GNUC__*100 + __GNUC_MINOR__ >= 601 && __OPTIMIZE__
CORRADE_EXPECT_FAIL("GCC 6.1+ misoptimizes and overwrites the value.");
#endif
CORRADE_COMPARE(a, (Vector4{1.0f, 2.0f, -3.0f, 4.5f}));
}
CORRADE_VERIFY((std::is_nothrow_constructible<Vector4, NoInitT>::value));
}

Loading…
Cancel
Save