From 8faa5243b5e78d25d78d6635bc80f8bc0afdbd9e Mon Sep 17 00:00:00 2001 From: a3d4 Date: Sat, 22 Aug 2020 00:01:29 +0200 Subject: [PATCH] Fix MSVC ADL --- cmake/EthCompilerSettings.cmake | 3 ++- libsolutil/CommonData.h | 7 +------ test/ExecutionFramework.cpp | 7 +++++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/cmake/EthCompilerSettings.cmake b/cmake/EthCompilerSettings.cmake index 3bcdad47b..653c5fdc3 100644 --- a/cmake/EthCompilerSettings.cmake +++ b/cmake/EthCompilerSettings.cmake @@ -157,9 +157,10 @@ elseif (DEFINED MSVC) add_compile_options(/wd4800) # disable forcing value to bool 'true' or 'false' (performance warning) (4800) add_compile_options(-D_WIN32_WINNT=0x0600) # declare Windows Vista API requirement add_compile_options(-DNOMINMAX) # undefine windows.h MAX && MIN macros cause it cause conflicts with std::min && std::max functions - 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(-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 set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4221") diff --git a/libsolutil/CommonData.h b/libsolutil/CommonData.h index 5fe0c2bfb..b01e24c38 100644 --- a/libsolutil/CommonData.h +++ b/libsolutil/CommonData.h @@ -37,10 +37,7 @@ #include #include -namespace std -{ - -/// Operator overloads for STL containers should be in std namespace for ADL to work properly. +/// Operators need to stay in the global namespace. /// Concatenate the contents of a container onto a vector template std::vector& operator+=(std::vector& _a, U& _b) @@ -147,8 +144,6 @@ inline std::multiset& operator-=(std::multiset& _a, C const& _b) return _a; } -} // end namespace std - namespace solidity::util { diff --git a/test/ExecutionFramework.cpp b/test/ExecutionFramework.cpp index b3841f6b4..7f5dfcf74 100644 --- a/test/ExecutionFramework.cpp +++ b/test/ExecutionFramework.cpp @@ -97,12 +97,15 @@ u256 ExecutionFramework::gasLimit() 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 { - return {EVMHost::convertFromEVMC( + return u256{EVMHost::convertFromEVMC( m_evmHost->get_block_hash(static_cast(_number & numeric_limits::max())) )}; }