Naios / function2

Improved and configurable drop-in replacement to std::function that supports move only types, multiple overloads and more
http://naios.github.io/function2
Boost Software License 1.0
539 stars 47 forks source link

Won't compile with Visual Studio 2019 16.3, 16.2 works good. #29

Closed ZeikoRomsan1 closed 4 years ago

ZeikoRomsan1 commented 4 years ago

@Naios

Error in VS 16.3:

error C2440: 'static_cast': cannot convert from 'fu2::abi_400::detail::type_erasure::erasure<true,Config,fu2::abi_400::detail::property<true,false,void (void )>>' to 'erasure_t &' error C2440: with error C2440: [ error C2440: Config=fu2::abi_400::detail::config<true,false,fu2::capacity_default> error C2440: ]

Commit Hash

5dcbecd91b60f50560b1be055f1603f3b715b5e1

Expected Behavior

Should compile

Actual Behavior

Won't compile

Steps to Reproduce

Try and compile uwebsockets with Visual Studio 2019 16.3 I also created an issue here: https://github.com/uNetworking/uWebSockets/issues/940 However I think the issue only is in the function2 lib.

Your Environment

Windows 10, x64 Visual Studio 2019 16.3 MSVC V142

Naios commented 4 years ago

Thanks for your issue report.

Unfortunatly your bug report is incomplete and misses a minimalistic reproducible example of the build error which is based on the current revision 5dcbecd. uNetworking/uWebSockets uses a revision which is from January so it's not up to date and can't be used as a reference.

ZeikoRomsan1 commented 4 years ago

Hello @Naios ,

Here is a minimalistic reprodusable example:

include "function2/function2.hpp"

int main() { fu2::unique_function<void()> test; test(); }

Which gives this error in VS 2019 16.3: function2\function2.hpp(725,1): error C2440: 'static_cast': cannot convert from 'fu2::abi_400::detail::type_erasure::erasure<true,Config,fu2::abi_400::detail::property<true,false,void (void)>>' to 'erasure_t &' function2\function2.hpp(725,1): error C2440: with function2\function2.hpp(725,1): error C2440: [ function2\function2.hpp(725,1): error C2440: Config=fu2::abi_400::detail::config<true,false,fu2::capacity_default> function2\function2.hpp(725,1): error C2440: ] function2\function2.hpp(725,1): message : static_cast and safe_cast to reference can only be used for valid initializations or for lvalue casts between related classes function2\function2.hpp(725): message : while compiling class template member function 'Ret fu2::abi_400::detail::type_erasure::invocation_table::operator_impl<0,fu2::abi_400::detail::function<fu2::abi_400::detail::config<true,false,fu2::capacity_default>,fu2::abi_400::detail::property<true,false,void (void)>>,void (void)>::operator ()(void)' function2\function2.hpp(725): message : with function2\function2.hpp(725): message : [ function2\function2.hpp(725): message : Ret=void function2\function2.hpp(725): message : ] ConsoleApplication1.cpp(7): message : see reference to function template instantiation 'Ret fu2::abi_400::detail::type_erasure::invocation_table::operator_impl<0,fu2::abi_400::detail::function<fu2::abi_400::detail::config<true,false,fu2::capacity_default>,fu2::abi_400::detail::property<true,false,void (void)>>,void (void)>::operator ()(void)' being compiled ConsoleApplication1.cpp(7): message : with ConsoleApplication1.cpp(7): message : [ ConsoleApplication1.cpp(7): message : Ret=void ConsoleApplication1.cpp(7): message : ] function2\function2.hpp(1388): message : see reference to class template instantiation 'fu2::abi_400::detail::type_erasure::invocation_table::operator_impl<0,fu2::abi_400::detail::function<fu2::abi_400::detail::config<true,false,fu2::capacity_default>,fu2::abi_400::detail::property<true,false,void (void)>>,void (void)>' being compiled ConsoleApplication1.cpp(5): message : see reference to class template instantiation 'fu2::abi_400::detail::function<fu2::abi_400::detail::config<true,false,fu2::capacity_default>,fu2::abi_400::detail::property<true,false,void (void)>>' being compiled function2\function2.hpp(725,1): error C2064: term does not evaluate to a function taking 1 arguments

Rogiel commented 4 years ago

@Naios I have just updated to 16.3 and got a similar problem with continuable (but the problem is probably with function2). I will try to get a failing test-case and report back.

Naios commented 4 years ago

@Rogiel Continuable will be affected by this as well since a simple instantiation of unique_function will trigger the compile error. Meanwhile I could reproduce this with the following error log:

1>G:\Projekte\function2\include\function2/function2.hpp(771,1): error C2440: 'static_cast': cannot convert from 'fu2::abi_400::detail::type_erasure::erasure<true,Config,fu2::abi_400::detail::property<true,false,void (void)>>' to 'erasure_t &'
1>G:\Projekte\function2\include\function2/function2.hpp(771,1): error C2440:         with
1>G:\Projekte\function2\include\function2/function2.hpp(771,1): error C2440:         [
1>G:\Projekte\function2\include\function2/function2.hpp(771,1): error C2440:             Config=fu2::abi_400::detail::config<true,false,fu2::capacity_default>
1>G:\Projekte\function2\include\function2/function2.hpp(771,1): error C2440:         ]
1>G:\Projekte\function2\include\function2/function2.hpp(771,1): message : static_cast and safe_cast to reference can only be used for valid initializations or for lvalue casts between related classes
1>G:\Projekte\function2\include\function2/function2.hpp(771): message : while compiling class template member function 'Ret fu2::abi_400::detail::type_erasure::invocation_table::operator_impl<0,fu2::abi_400::detail::function<fu2::abi_400::detail::config<true,false,fu2::capacity_default>,fu2::abi_400::detail::property<true,false,void (void)>>,void (void)>::operator ()(void)'
1>G:\Projekte\function2\include\function2/function2.hpp(771): message :         with
1>G:\Projekte\function2\include\function2/function2.hpp(771): message :         [
1>G:\Projekte\function2\include\function2/function2.hpp(771): message :             Ret=void
1>G:\Projekte\function2\include\function2/function2.hpp(771): message :         ]
1>G:\Projekte\function2\test\playground.cpp(11): message : see reference to function template instantiation 'Ret fu2::abi_400::detail::type_erasure::invocation_table::operator_impl<0,fu2::abi_400::detail::function<fu2::abi_400::detail::config<true,false,fu2::capacity_default>,fu2::abi_400::detail::property<true,false,void (void)>>,void (void)>::operator ()(void)' being compiled
1>G:\Projekte\function2\test\playground.cpp(11): message :         with
1>G:\Projekte\function2\test\playground.cpp(11): message :         [
1>G:\Projekte\function2\test\playground.cpp(11): message :             Ret=void
1>G:\Projekte\function2\test\playground.cpp(11): message :         ]
1>G:\Projekte\function2\include\function2/function2.hpp(1435): message : see reference to class template instantiation 'fu2::abi_400::detail::type_erasure::invocation_table::operator_impl<0,fu2::abi_400::detail::function<fu2::abi_400::detail::config<true,false,fu2::capacity_default>,fu2::abi_400::detail::property<true,false,void (void)>>,void (void)>' being compiled
1>G:\Projekte\function2\test\playground.cpp(10): message : see reference to class template instantiation 'fu2::abi_400::detail::function<fu2::abi_400::detail::config<true,false,fu2::capacity_default>,fu2::abi_400::detail::property<true,false,void (void)>>' being compiled
1>G:\Projekte\function2\include\function2/function2.hpp(771,1): error C2064: term does not evaluate to a function taking 1 arguments
Naios commented 4 years ago

I came up with a workaround for this issue and reported it back to Microsoft https://developercommunity.visualstudio.com/content/problem/748886/compiler-regression-in-163-maybe-related-to-expres.html

ghost commented 4 years ago

Thanks for working on this and reporting it to MS