From 7df90af14410808df4069f30297a10a0e52fe008 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 23 May 2018 21:49:52 +0200 Subject: [PATCH] Math: work around MSVC 2017 15.7.2 ICEs. Reported here: https://developercommunity.visualstudio.com/content/problem/259204/1572-regression-ice-in-constexpr-code-involving-de.html --- src/Magnum/Math/Test/BezierTest.cpp | 10 ++++++++++ src/Magnum/Math/Test/Matrix3Test.cpp | 6 ++++++ src/Magnum/Math/Test/Matrix4Test.cpp | 7 +++++++ 3 files changed, 23 insertions(+) diff --git a/src/Magnum/Math/Test/BezierTest.cpp b/src/Magnum/Math/Test/BezierTest.cpp index b8bc58419..7e68db653 100644 --- a/src/Magnum/Math/Test/BezierTest.cpp +++ b/src/Magnum/Math/Test/BezierTest.cpp @@ -144,7 +144,12 @@ void BezierTest::constructNoInit() { } void BezierTest::constructConversion() { + #ifndef CORRADE_MSVC2017_COMPATIBILITY constexpr QuadraticBezier2Dd a{Vector2d{0.5, 1.0}, Vector2d{1.1, 0.3}, Vector2d{0.1, 1.2}}; + #else + /* https://developercommunity.visualstudio.com/content/problem/259204/1572-regression-ice-in-constexpr-code-involving-de.html */ + constexpr QuadraticBezier2Dd a{Vector<2, Double>{0.5, 1.0}, Vector<2, Double>{1.1, 0.3}, Vector<2, Double>{0.1, 1.2}}; + #endif constexpr QuadraticBezier2D b{a}; CORRADE_COMPARE(b, (QuadraticBezier2D{Vector2{0.5f, 1.0f}, Vector2{1.1f, 0.3f}, Vector2{0.1f, 1.2f}})); @@ -166,7 +171,12 @@ void BezierTest::constructCopy() { void BezierTest::convert() { constexpr QBezier2D a{0.5f, 1.1f, 0.1f, 1.0f, 0.3f, 1.2f}; + #ifndef CORRADE_MSVC2017_COMPATIBILITY constexpr QuadraticBezier2D b{Vector2{0.5f, 1.0f}, Vector2{1.1f, 0.3f}, Vector2{0.1f, 1.2f}}; + #else + /* https://developercommunity.visualstudio.com/content/problem/259204/1572-regression-ice-in-constexpr-code-involving-de.html */ + constexpr QuadraticBezier2D b{Vector<2, Float>{0.5f, 1.0f}, Vector<2, Float>{1.1f, 0.3f}, Vector<2, Float>{0.1f, 1.2f}}; + #endif constexpr QuadraticBezier2D c{a}; CORRADE_COMPARE(c, b); diff --git a/src/Magnum/Math/Test/Matrix3Test.cpp b/src/Magnum/Math/Test/Matrix3Test.cpp index 2f88d02d7..85ae84d26 100644 --- a/src/Magnum/Math/Test/Matrix3Test.cpp +++ b/src/Magnum/Math/Test/Matrix3Test.cpp @@ -340,8 +340,14 @@ void Matrix3Test::projection() { } void Matrix3Test::fromParts() { + #ifndef CORRADE_MSVC2017_COMPATIBILITY constexpr Matrix2x2 rotationScaling(Vector2(3.0f, 5.0f), Vector2(4.0f, 4.0f)); + #else + /* https://developercommunity.visualstudio.com/content/problem/259204/1572-regression-ice-in-constexpr-code-involving-de.html */ + constexpr Matrix2x2 rotationScaling{Vector<2, Float>{3.0f, 5.0f}, + Vector<2, Float>{4.0f, 4.0f}}; + #endif constexpr Vector2 translation(7.0f, -1.0f); #ifndef CORRADE_MSVC2015_COMPATIBILITY /* Probably because copy is not constexpr */ constexpr diff --git a/src/Magnum/Math/Test/Matrix4Test.cpp b/src/Magnum/Math/Test/Matrix4Test.cpp index 5c1c185d2..14364edc6 100644 --- a/src/Magnum/Math/Test/Matrix4Test.cpp +++ b/src/Magnum/Math/Test/Matrix4Test.cpp @@ -479,9 +479,16 @@ void Matrix4Test::perspectiveProjectionFovInfiniteFar() { } void Matrix4Test::fromParts() { + #ifndef CORRADE_MSVC2017_COMPATIBILITY constexpr Matrix3x3 rotationScaling(Vector3(3.0f, 5.0f, 8.0f), Vector3(4.0f, 4.0f, 7.0f), Vector3(7.0f, -1.0f, 8.0f)); + #else + /* https://developercommunity.visualstudio.com/content/problem/259204/1572-regression-ice-in-constexpr-code-involving-de.html */ + constexpr Matrix3x3 rotationScaling{Vector<3, Float>{3.0f, 5.0f, 8.0f}, + Vector<3, Float>{4.0f, 4.0f, 7.0f}, + Vector<3, Float>{7.0f, -1.0f, 8.0f}}; + #endif constexpr Vector3 translation(9.0f, 4.0f, 5.0f); #ifndef CORRADE_MSVC2015_COMPATIBILITY /* Probably because copy is not constexpr */ constexpr