Merge pull request #9655 from a3d4/fix-msvc-adl

Fix MSVC ADL
This commit is contained in:
chriseth 2020-09-01 10:35:11 +02:00 committed by GitHub
commit f628fd3f03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 9 deletions

View File

@ -160,6 +160,7 @@ elseif (DEFINED MSVC)
add_compile_options(/utf-8) # enable utf-8 encoding (solves warning 4819) add_compile_options(/utf-8) # enable utf-8 encoding (solves warning 4819)
add_compile_options(-DBOOST_REGEX_NO_LIB) # disable automatic boost::regex library selection add_compile_options(-DBOOST_REGEX_NO_LIB) # disable automatic boost::regex library selection
add_compile_options(-D_REGEX_MAX_STACK_COUNT=200000L) # increase std::regex recursion depth limit add_compile_options(-D_REGEX_MAX_STACK_COUNT=200000L) # increase std::regex recursion depth limit
add_compile_options(/permissive-) # specify standards conformance mode to the compiler
# disable empty object file warning # disable empty object file warning
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4221") set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4221")

View File

@ -37,10 +37,7 @@
#include <utility> #include <utility>
#include <type_traits> #include <type_traits>
namespace std /// Operators need to stay in the global namespace.
{
/// Operator overloads for STL containers should be in std namespace for ADL to work properly.
/// Concatenate the contents of a container onto a vector /// Concatenate the contents of a container onto a vector
template <class T, class U> std::vector<T>& operator+=(std::vector<T>& _a, U& _b) template <class T, class U> std::vector<T>& operator+=(std::vector<T>& _a, U& _b)
@ -147,8 +144,6 @@ inline std::multiset<T...>& operator-=(std::multiset<T...>& _a, C const& _b)
return _a; return _a;
} }
} // end namespace std
namespace solidity::util namespace solidity::util
{ {

View File

@ -97,12 +97,15 @@ u256 ExecutionFramework::gasLimit() const
u256 ExecutionFramework::gasPrice() const u256 ExecutionFramework::gasPrice() const
{ {
return {EVMHost::convertFromEVMC(m_evmHost->tx_context.tx_gas_price)}; // here and below we use "return u256{....}" instead of just "return {....}"
// to please MSVC and avoid unexpected
// warning C4927 : illegal conversion; more than one user - defined conversion has been implicitly applied
return u256{EVMHost::convertFromEVMC(m_evmHost->tx_context.tx_gas_price)};
} }
u256 ExecutionFramework::blockHash(u256 const& _number) const u256 ExecutionFramework::blockHash(u256 const& _number) const
{ {
return {EVMHost::convertFromEVMC( return u256{EVMHost::convertFromEVMC(
m_evmHost->get_block_hash(static_cast<int64_t>(_number & numeric_limits<uint64_t>::max())) m_evmHost->get_block_hash(static_cast<int64_t>(_number & numeric_limits<uint64_t>::max()))
)}; )};
} }