-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Open
Labels
Description
Description
After the MSVC team implemented P2468R2 The Equality Operator You Are Looking For, we got compiler errors with /std:c++latest like below. The way this fails is that the != operator here: https://github.com/nlohmann/json/blob/develop/include/nlohmann/json.hpp#L3704 actually suppresses the rewritten operator candidates and stops the code from compiling because the rewritten candidates are discarded. Could you please look this issue? Thanks.
Note: this issue will be reproduced on next release version of VS(17.6 or later).
Reproduction steps
- open VS2019 x64 tools command (Or VS2022)
- git clone https://github.com/nlohmann/json F:\gitP\nlohmann\json
- mkdir F:\gitP\nlohmann\json\build_amd64
- cd F:\gitP\nlohmann\json\build_amd64
- cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_SYSTEM_VERSION=10.0.18362.0 -DJSON_BuildTests=On ..
- set CL= /std:c++latest
- msbuild /m /p:Platform=x64 /p:Configuration=Release nlohmann_json.sln /t:Rebuild
Expected vs. actual results
Expected Result:
The build was successful.
Actual Result:
build.log: JSON_amd64_build.log
unit-constructor1.cpp
F:\gitP\nlohmann\json\tests\src\unit-constructor1.cpp(282,13): error C2088: '==': illegal for class
unit-iterators2.cpp
F:\gitP\nlohmann\json\tests\src\unit-iterators2.cpp(946,17): error C2678: binary '==': no operator found which takes a left-hand operand of type 'nlohmann::json_abi_v3_11_2::json' (or there is no acceptable conversion)
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include\thread(242,36): note: could be 'bool std::operator ==(std::thread::id,std::thread::id) noexcept' [found using argument-dependent lookup]
F:\gitP\nlohmann\json\include\nlohmann/json.hpp(3680,10): note: or 'bool nlohmann::json_abi_v3_11_2::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::json_abi_v3_11_2::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>,void>::operator ==(const nlohmann::json_abi_v3_11_2::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::json_abi_v3_11_2::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>,void> &) noexcept const' [synthesized expression 'y == x']
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include\thread(242,36): note: or 'bool std::operator ==(std::thread::id,std::thread::id) noexcept' [synthesized expression 'y == x']
F:\gitP\nlohmann\json\tests\thirdparty\doctest\doctest.h(1238,9): note: or 'unknown-type doctest::detail::Expression_lhs<std::ranges::reverse_view<std::ranges::ref_view<nlohmann::json_abi_v3_11_2::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::json_abi_v3_11_2::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>,void>>> &>::operator ==(R &&)'
F:\gitP\nlohmann\json\tests\src\unit-iterators2.cpp(946,17): note: Failed to specialize function template 'unknown-type doctest::detail::Expression_lhs<std::ranges::reverse_view<std::ranges::ref_view<nlohmann::json_abi_v3_11_2::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::json_abi_v3_11_2::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>,void>>> &>::operator ==(R &&)'
F:\gitP\nlohmann\json\tests\src\unit-iterators2.cpp(946,17): note: With the following template arguments:
F:\gitP\nlohmann\json\tests\src\unit-iterators2.cpp(946,17): note: 'R=nlohmann::json_abi_v3_11_2::json &'
F:\gitP\nlohmann\json\include\nlohmann/json.hpp(3697,10): note: or 'bool nlohmann::json_abi_v3_11_2::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::json_abi_v3_11_2::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>,void>::operator ==(ScalarType) noexcept const' [synthesized expression 'y == x']
F:\gitP\nlohmann\json\tests\src\unit-iterators2.cpp(946,17): note: the associated constraints are not satisfied
F:\gitP\nlohmann\json\include\nlohmann/json.hpp(3696,14): note: the constraint was not satisfied
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include\utility(367,27): note: or 'bool std::operator ==(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)'
F:\gitP\nlohmann\json\tests\src\unit-iterators2.cpp(946,17): note: 'bool std::operator ==(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)': could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from
F:\gitP\nlohmann\json\tests\src\unit-iterators2.cpp(946,17): error C2660: 'doctest::detail::decomp_assert': function does not take 4 arguments
F:\gitP\nlohmann\json\tests\thirdparty\doctest\doctest.h(1425,28): note: see declaration of 'doctest::detail::decomp_assert'
F:\gitP\nlohmann\json\tests\src\unit-iterators2.cpp(946,17): note: while trying to match the argument list '(doctest::assertType::Enum, const char [52], int, const char [23])'
Minimal code example
No response
Error messages
No response
Compiler and operating system
Internal unreleased MSVC
Library version
develop branch of 8f83153
Validation
- The bug also occurs if the latest version from the
developbranch is used. - I can successfully compile and run the unit tests.
lucidBrot