diff --git a/src/Magnum/Math/Test/AngleTest.cpp b/src/Magnum/Math/Test/AngleTest.cpp index 5cc6056be..f27d646e9 100644 --- a/src/Magnum/Math/Test/AngleTest.cpp +++ b/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::value)); CORRADE_VERIFY((std::is_nothrow_constructible::value)); diff --git a/src/Magnum/Math/Test/BezierTest.cpp b/src/Magnum/Math/Test/BezierTest.cpp index 86354a47c..04afa111d 100644 --- a/src/Magnum/Math/Test/BezierTest.cpp +++ b/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::value)); } diff --git a/src/Magnum/Math/Test/BoolVectorTest.cpp b/src/Magnum/Math/Test/BoolVectorTest.cpp index a380b34f8..a5777762f 100644 --- a/src/Magnum/Math/Test/BoolVectorTest.cpp +++ b/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::value)); } diff --git a/src/Magnum/Math/Test/ColorTest.cpp b/src/Magnum/Math/Test/ColorTest.cpp index eb7dd5a9b..014a2cb8a 100644 --- a/src/Magnum/Math/Test/ColorTest.cpp +++ b/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::value)); CORRADE_VERIFY((std::is_nothrow_constructible::value)); diff --git a/src/Magnum/Math/Test/ComplexTest.cpp b/src/Magnum/Math/Test/ComplexTest.cpp index b5ca99653..8c46d13e1 100644 --- a/src/Magnum/Math/Test/ComplexTest.cpp +++ b/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::value)); } diff --git a/src/Magnum/Math/Test/DualComplexTest.cpp b/src/Magnum/Math/Test/DualComplexTest.cpp index 033f4d710..026a5ca56 100644 --- a/src/Magnum/Math/Test/DualComplexTest.cpp +++ b/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::value)); } diff --git a/src/Magnum/Math/Test/DualQuaternionTest.cpp b/src/Magnum/Math/Test/DualQuaternionTest.cpp index 338ededaf..372eaf572 100644 --- a/src/Magnum/Math/Test/DualQuaternionTest.cpp +++ b/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::value)); } diff --git a/src/Magnum/Math/Test/DualTest.cpp b/src/Magnum/Math/Test/DualTest.cpp index 973b56f7c..d7cd29c4c 100644 --- a/src/Magnum/Math/Test/DualTest.cpp +++ b/src/Magnum/Math/Test/DualTest.cpp @@ -137,8 +137,13 @@ void DualTest::constructNoInit() { Math::Dual> 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>{NoInit}; - CORRADE_COMPARE(a, Dual(2.0f, -7.5f)); - CORRADE_COMPARE(b, (Math::Dual>{{{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>{{{3.0f, 0.1f, 1.0f}, 1.0f}, {{0.1f, 0.0f, 1.0f}, 0.3f}})); + } CORRADE_VERIFY((std::is_nothrow_constructible::value)); CORRADE_VERIFY((std::is_nothrow_constructible>, NoInitT>::value)); diff --git a/src/Magnum/Math/Test/Matrix3Test.cpp b/src/Magnum/Math/Test/Matrix3Test.cpp index 322181471..25758233e 100644 --- a/src/Magnum/Math/Test/Matrix3Test.cpp +++ b/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::value)); } diff --git a/src/Magnum/Math/Test/Matrix4Test.cpp b/src/Magnum/Math/Test/Matrix4Test.cpp index 7cce470c9..e33f9bda7 100644 --- a/src/Magnum/Math/Test/Matrix4Test.cpp +++ b/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::value)); } diff --git a/src/Magnum/Math/Test/MatrixTest.cpp b/src/Magnum/Math/Test/MatrixTest.cpp index 8b124f0a7..974bebe35 100644 --- a/src/Magnum/Math/Test/MatrixTest.cpp +++ b/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::value)); } diff --git a/src/Magnum/Math/Test/QuaternionTest.cpp b/src/Magnum/Math/Test/QuaternionTest.cpp index e85fd26dc..814b0d558 100644 --- a/src/Magnum/Math/Test/QuaternionTest.cpp +++ b/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::value)); } diff --git a/src/Magnum/Math/Test/RangeTest.cpp b/src/Magnum/Math/Test/RangeTest.cpp index d1efadc7e..ad869b6e2 100644 --- a/src/Magnum/Math/Test/RangeTest.cpp +++ b/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::value)); CORRADE_VERIFY((std::is_nothrow_constructible::value)); diff --git a/src/Magnum/Math/Test/RectangularMatrixTest.cpp b/src/Magnum/Math/Test/RectangularMatrixTest.cpp index d1adf3735..c26676375 100644 --- a/src/Magnum/Math/Test/RectangularMatrixTest.cpp +++ b/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::value)); } diff --git a/src/Magnum/Math/Test/UnitTest.cpp b/src/Magnum/Math/Test/UnitTest.cpp index 0bbf1a7ed..4cb58e33a 100644 --- a/src/Magnum/Math/Test/UnitTest.cpp +++ b/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::value)); } diff --git a/src/Magnum/Math/Test/Vector2Test.cpp b/src/Magnum/Math/Test/Vector2Test.cpp index 55bee65e3..774f584fd 100644 --- a/src/Magnum/Math/Test/Vector2Test.cpp +++ b/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::value)); } diff --git a/src/Magnum/Math/Test/Vector3Test.cpp b/src/Magnum/Math/Test/Vector3Test.cpp index 72c5be4c1..044f87ef8 100644 --- a/src/Magnum/Math/Test/Vector3Test.cpp +++ b/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::value)); } diff --git a/src/Magnum/Math/Test/Vector4Test.cpp b/src/Magnum/Math/Test/Vector4Test.cpp index 2dcce57b8..e89ee1382 100644 --- a/src/Magnum/Math/Test/Vector4Test.cpp +++ b/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::value)); } diff --git a/src/Magnum/Math/Test/VectorTest.cpp b/src/Magnum/Math/Test/VectorTest.cpp index 5c754a3b6..5204a0b2e 100644 --- a/src/Magnum/Math/Test/VectorTest.cpp +++ b/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::value)); }