Browse Source

Math: work around a MSVC 2017 15.8 ICE.

Four hours of my life, gone. Minimal repro case here:
https://twitter.com/czmosra/status/1038610648568147968
pull/284/head
Vladimír Vondruš 8 years ago
parent
commit
b44166b238
  1. 8
      doc/changelog.dox
  2. 14
      src/Magnum/Math/Color.h

8
doc/changelog.dox

@ -311,6 +311,14 @@ See also:
@subsection changelog-latest-bugfixes Bug fixes
- MSVC 15.8 (released on Aug 14, 2018) has a regression causing the compiler
to crash with an ICE (C1001) on @ref Math::Color4 constructors that have a
default alpha parameter. This is only only when the `/permissive-` flag is
specified (which is done by default for projects created directly using
Visual Studio but not for projects using CMake). This has been worked
around, but can't be guaranteed it was the only case. In case you're
experiencing a similar issue somewhere else, please try to disable the
`/permissive-` flag first.
- An assert was firing during @ref Platform::GlfwApplication initialization
due to a pointer not being properly initialized after the
@ref Platform::GlfwApplication::GLConfiguration "GLConfiguration" rework in

14
src/Magnum/Math/Color.h

@ -197,12 +197,26 @@ template<class T> inline Vector3<typename Color3<T>::FloatingPointType> toXyz(ty
}
/* Value for full channel (1.0f for floats, 255 for unsigned byte) */
#if !defined(CORRADE_MSVC2017_COMPATIBILITY) || defined(CORRADE_MSVC2015_COMPATIBILITY)
/* MSVC 2017 since 15.8 crashes with the following at a constructor line that
calls this function via a default parameter. This happens only when the
/permissive- (yes, there's a dash at the end) flag is specified, which is
projects created directly using VS (enabled by default since 15.5) but not
projects using CMake. Not using SFINAE in this case makes it work. Minimal
repro case here: https://twitter.com/czmosra/status/1038610648568147968 */
template<class T> constexpr typename std::enable_if<std::is_floating_point<T>::value, T>::type fullChannel() {
return T(1);
}
template<class T> constexpr typename std::enable_if<std::is_integral<T>::value, T>::type fullChannel() {
return Implementation::bitMax<T>();
}
#else
template<class T> constexpr T fullChannel() { return bitMax<T>(); }
/** @todo half */
template<> constexpr float fullChannel<float>() { return 1.0f; }
template<> constexpr double fullChannel<double>() { return 1.0; }
template<> constexpr long double fullChannel<long double>() { return 1.0l; }
#endif
}

Loading…
Cancel
Save