ned14 / status-code

Proposed SG14 status_code for the C++ standard

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bit_cast: ambiguous call to overloaded function

Tradias opened this issue · comments

Compiling with MSVC 14.28.29910 and C++20 I am getting the following compile error. I have not managed to create a minimal example, but since std::bit_cast is available now it probably makes sense to switch to it in any case.

[build] C:\Boost\include\boost-1_76\boost\outcome\experimental\status-code\config.hpp(271): error C2668: 'system_error2::detail::bit_cast': ambiguous call to overloaded function
[build] C:\Boost\include\boost-1_76\boost\outcome\experimental\status-code\config.hpp(216): note: could be 'To system_error2::detail::bit_cast<To,From,true>(const From &) noexcept'
[build]         with
[build]         [
[build]             To=__int64,
[build]             From=AllocatedValue<15524508317838324489,std::string>
[build]         ]
[build] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\include\bit(33): note: or       '_To std::bit_cast<To,From,0>(const _From &) noexcept' [found using argument-dependent lookup]
[build]         with
[build]         [
[build]             _To=__int64,
[build]             To=__int64,
[build]             From=AllocatedValue<15524508317838324489,std::string>,
[build]             _From=AllocatedValue<15524508317838324489,std::string>
[build]         ]
[build] C:\Boost\include\boost-1_76\boost\outcome\experimental\status-code\config.hpp(271): note: while trying to match the argument list '(const From)'
[build]         with
[build]         [
[build]             From=AllocatedValue<15524508317838324489,std::string>
[build]         ]
[build] C:\Boost\include\boost-1_76\boost\outcome\experimental\status-code\status_code.hpp(543): note: see reference to function template instantiation 'To system_error2::detail::erasure_cast<__int64,AllocatedValue<15524508317838324489,std::string>,true>(const From &) noexcept' being compiled
[build]         with
[build]         [
[build]             To=__int64,
[build]             From=AllocatedValue<15524508317838324489,std::string>
[build]         ]
[build] C:\src\outcome/stringStatusCode.h(5): note: see reference to function template instantiation 'system_error2::status_code<system_error2::erased<intptr_t,true>>::status_code<Derived,true>(system_error2::status_code<Derived> &&) noexcept' being compiled
[build]         with
[build]         [
[build]             Derived=BasicStringStatusCodeDomain<15524508317838324489>
[build]         ]
[build] C:\src\outcome/stringStatusCode.h(5): note: see reference to function template instantiation 'system_error2::status_code<system_error2::erased<intptr_t,true>>::status_code<Derived,true>(system_error2::status_code<Derived> &&) noexcept' being compiled
[build]         with
[build]         [
[build]             Derived=BasicStringStatusCodeDomain<15524508317838324489>
[build]         ]

This is definitely a bug in status code, not outcome, so transferring. quickcpplib has an implementation of this exact code sequence which preferentially chooses std::bit_cast when it is available, so that ought to be transplanted into here.

Thanks for the BR, and my apologies for not doing this work sooner (I forgot!)

Ok, give that commit a try there and see how it goes for you.

Yes that seems to work. Thank you

Thanks for the confirm and BR!