Repository navigation
Another compilation failure with Visual Studio #2007
Copy link
Copy link
Closed
Labels
kind: bugplatform: visual studiorelated to MSVCrelated to MSVCstate: stalethe issue has not been updated in a while and will be closed automatically soon unless it is updatedthe issue has not been updated in a while and will be closed automatically soon unless it is updated
Description
The following new test case fails to compile with at least Visual Studio 2015 14.0.25431.01 Update 3, and Visual Studio 2019 16.5.0. Related to #167.
#include <nlohmann/json.hpp>
TEST_CASE("JSON pointers")
{
SECTION("op<<")
{
nlohmann::basic_json<std::map, std::vector, std::string, bool, int32_t> a_different_instantiation_of_basic_json;
nlohmann::json::json_pointer ptr;
CHECK(ptr == ptr);
}
}The error message is:
nlohmann-json\test\thirdparty\doctest\doctest.h(782,1): error C2593: 'operator <<' is ambiguous
nlohmann-json\single_include\nlohmann/json.hpp(20642,26): message : could be 'std::ostream &nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>::operator <<(std::ostream &,const nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer> &)' [found using argument-dependent lookup]
nlohmann-json\single_include\nlohmann/json.hpp(20642,26): message : or 'std::ostream &nlohmann::basic_json<std::map,std::vector,std::string,bool,int32_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>::operator <<(std::ostream &,const nlohmann::basic_json<std::map,std::vector,std::string,bool,int32_t,uint64_t,double,std::allocator,nlohmann::adl_serializer> &)' [found using argument-dependent lookup]
nlohmann-json\test\thirdparty\doctest\doctest.h(782,1): message : while trying to match the argument list '(std::ostream, const T)'
with
[
T=nlohmann::json_pointer<nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>>
]
nlohmann-json\test\thirdparty\doctest\doctest.h(788): message : see reference to class template instantiation 'doctest::detail::has_insertion_operator_impl::has_insertion_operator<T>' being compiled
with
[
T=nlohmann::json_pointer<nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>>
]
nlohmann-json\test\thirdparty\doctest\doctest.h(828): message : see reference to class template instantiation 'doctest::detail::has_insertion_operator<T>' being compiled
with
[
T=nlohmann::json_pointer<nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>>
]
nlohmann-json\test\thirdparty\doctest\doctest.h(854): message : see reference to class template instantiation 'doctest::StringMaker<T>' being compiled
with
[
T=nlohmann::json_pointer<nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>>
]
nlohmann-json\test\thirdparty\doctest\doctest.h(1011): message : see reference to function template instantiation 'doctest::String doctest::toString<L>(const T &)' being compiled
with
[
L=nlohmann::json_pointer<nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>>,
T=nlohmann::json_pointer<nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>>
]
nlohmann-json\test\thirdparty\doctest\doctest.h(1159): message : see reference to function template instantiation 'doctest::String doctest::detail::stringifyBinaryExpr<nlohmann::json_pointer<nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>>,R>(const L &,const char *,const R &)' being compiled
with
[
R=nlohmann::json_pointer<nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>>,
L=nlohmann::json_pointer<nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>>
]
nlohmann-json\test\src\foo.cpp(8): message : see reference to function template instantiation 'doctest::detail::Result doctest::detail::Expression_lhs<const nlohmann::json_pointer<nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>> &>::operator ==<nlohmann::json_pointer<nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>>>(const R &)' being compiled
with
[
R=nlohmann::json_pointer<nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>>
]
nlohmann-json\test\src\foo.cpp(8): message : see reference to function template instantiation 'doctest::detail::Result doctest::detail::Expression_lhs<const nlohmann::json_pointer<nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>> &>::operator ==<nlohmann::json_pointer<nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>>>(const R &)' being compiled
with
[
R=nlohmann::json_pointer<nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>>
]
Metadata
Metadata
Assignees
Labels
kind: bugplatform: visual studiorelated to MSVCrelated to MSVCstate: stalethe issue has not been updated in a while and will be closed automatically soon unless it is updatedthe issue has not been updated in a while and will be closed automatically soon unless it is updated
Activity
emmenlau commentedon Apr 1, 2020
Yep, we get the same problem after switching from VS2019.3 to VS2019.5.
MarvinSchultz commentedon Apr 8, 2020
Is there any known workaround?
subhardw commentedon Apr 11, 2020
Just spent couple of hours on this issue and I can confirm I have a repro. I don't have a good reason why this is happening. Let me invest more time over the weekend and next week and see I can figure out why ADL is making this break.
As for workaround @MarvinSchultz , this compiled for me:
Does this work for you? I am running VS 16.5.3 and cl.exe 19.25.28612.0.
If there is another MSVC issue, please do tag me. Thank you!
garethsb commentedon Apr 14, 2020
That "workaround" isn't really a workaround, really, because by changing
int32_ttoint64_t, the typea_different_instantiation_of_basic_jsonis not actually different.t-b commentedon Apr 14, 2020
How about adding a PR with that new test case and then we can check which compilers accept that and which not?
stale commentedon May 15, 2020
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.