mpark / variant

C++17 `std::variant` for C++11/14/17
https://mpark.github.io/variant
Boost Software License 1.0
659 stars 88 forks source link

Fails to compile with MSVC 19.15 #48

Closed mgieseki closed 5 years ago

mgieseki commented 5 years ago

Microsoft managed to break the successful compilation of the variant sources again. The latest update of MS Visual Studio 2017 (version 15.8, MSVC 19.15) produces messages like these:

vartest.cpp(935): error C2131: expression did not evaluate to a constant
vartest.cpp(935): note: failure was caused by a read of a variable outside its lifetime
vartest.cpp(935): note: see usage of '<traits_0>'
vartest.cpp(1754): note: see reference to class template instantiation 'mpark::detail::traits<int>' being compiled
vartest.cpp(2053): note: see reference to class template instantiation 'mpark::detail::impl<int>' being compiled
vartest.cpp(2460): note: see reference to class template instantiation 'mpark::variant<int>' being compiled
vartest.cpp(963): error C2131: expression did not evaluate to a constant
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include\initializer_list(42): note: failure was caused by non-constant arguments or reference to a non-constant symbol
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include\initializer_list(42): note: see usage of '$S3'
vartest.cpp(968): error C2131: expression did not evaluate to a constant
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include\initializer_list(42): note: failure was caused by non-constant arguments or reference to a non-constant symbol
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include\initializer_list(42): note: see usage of '$S5'
vartest.cpp(973): error C2131: expression did not evaluate to a constant
vartest.cpp(973): note: failure was caused by a read of an uninitialized symbol
vartest.cpp(973): note: see usage of 'copy_constructible_trait'
vartest.cpp(979): error C2131: expression did not evaluate to a constant
vartest.cpp(979): note: failure was caused by a read of an uninitialized symbol
vartest.cpp(979): note: see usage of 'move_constructible_trait'
vartest.cpp(985): error C2131: expression did not evaluate to a constant
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include\initializer_list(42): note: failure was caused by non-constant arguments or reference to a non-constant symbol
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include\initializer_list(42): note: see usage of '$S7'
vartest.cpp(1754): error C2975: 'unnamed-parameter': invalid template argument for 'mpark::detail::copy_assignment', expected compile-time constant expression
vartest.cpp(1716): note: see declaration of 'unnamed-parameter'
vartest.cpp(1754): error C2440: 'specialization': cannot convert from 'int' to 'mpark::detail::Trait'
vartest.cpp(1754): note: Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast)
vartest.cpp(1738): error C2975: 'unnamed-parameter': invalid template argument for 'mpark::detail::move_assignment', expected compile-time constant expression
vartest.cpp(1676): note: see declaration of 'unnamed-parameter'
vartest.cpp(1754): note: see reference to class template instantiation 'mpark::detail::copy_assignment<mpark::detail::traits<int>,0>' being compiled
vartest.cpp(1738): error C2440: 'specialization': cannot convert from 'int' to 'mpark::detail::Trait'
vartest.cpp(1738): note: Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast)
vartest.cpp(1594): error C2975: 'unnamed-parameter': invalid template argument for 'mpark::detail::copy_constructor', expected compile-time constant expression
vartest.cpp(1556): note: see declaration of 'unnamed-parameter'
vartest.cpp(1698): note: see reference to class template instantiation 'mpark::detail::assignment<mpark::detail::traits<int>>' being compiled
vartest.cpp(1738): note: see reference to class template instantiation 'mpark::detail::move_assignment<mpark::detail::traits<int>,0>' being compiled
vartest.cpp(1594): error C2440: 'specialization': cannot convert from 'int' to 'mpark::detail::Trait'
vartest.cpp(1594): note: Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast)
vartest.cpp(1578): error C2975: 'unnamed-parameter': invalid template argument for 'mpark::detail::move_constructor', expected compile-time constant expression
vartest.cpp(1518): note: see declaration of 'unnamed-parameter'
vartest.cpp(1594): note: see reference to class template instantiation 'mpark::detail::copy_constructor<Traits,0>' being compiled
        with
        [
            Traits=mpark::detail::traits<int>
        ]
vartest.cpp(1578): error C2440: 'specialization': cannot convert from 'int' to 'mpark::detail::Trait'
vartest.cpp(1578): note: Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast)
vartest.cpp(1471): error C2975: 'unnamed-parameter': invalid template argument for 'mpark::detail::destructor', expected compile-time constant expression
vartest.cpp(1423): note: see declaration of 'unnamed-parameter'
vartest.cpp(1540): note: see reference to class template instantiation 'mpark::detail::constructor<mpark::detail::traits<int>>' being compiled
vartest.cpp(1578): note: see reference to class template instantiation 'mpark::detail::move_constructor<mpark::detail::traits<int>,0>' being compiled
vartest.cpp(1471): error C2440: 'specialization': cannot convert from 'int' to 'mpark::detail::Trait'
vartest.cpp(1471): note: Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast)
vartest.cpp(1472): error C2975: 'unnamed-parameter': invalid template argument for 'mpark::detail::destructor', expected compile-time constant expression
vartest.cpp(1423): note: see declaration of 'unnamed-parameter'
vartest.cpp(1472): error C2440: 'specialization': cannot convert from 'int' to 'mpark::detail::Trait'
vartest.cpp(1472): note: Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast)
vartest.cpp(1595): error C2975: 'unnamed-parameter': invalid template argument for 'mpark::detail::copy_constructor', expected compile-time constant expression
vartest.cpp(1556): note: see declaration of 'unnamed-parameter'
vartest.cpp(1595): error C2440: 'specialization': cannot convert from 'int' to 'mpark::detail::Trait'
vartest.cpp(1595): note: Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast)
vartest.cpp(1755): error C2975: 'unnamed-parameter': invalid template argument for 'mpark::detail::copy_assignment', expected compile-time constant expression
vartest.cpp(1716): note: see declaration of 'unnamed-parameter'
vartest.cpp(1755): error C2440: 'specialization': cannot convert from 'int' to 'mpark::detail::Trait'
vartest.cpp(1755): note: Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast)
Tilka commented 5 years ago

Probably a compiler bug. Someone already reported a similar problem.

Mystfit commented 5 years ago

I can confirm this. I'm receiving the same error with Visual Studio Community 2017 15.8.1

mpark commented 5 years ago

Fixed the root cause in 657110d5ea11f344d29bce1d9609c7d76696cb64

DanGroomMPG commented 5 years ago

So... not a compiler bug?

tomalakgeretkal commented 4 years ago

So... not a compiler bug?

Read the commit message.