- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 7.2k
 
Open
Labels
kind: bugplatform: visual studiorelated to MSVCrelated to MSVCstate: help neededthe issue needs help to proceedthe issue needs help to proceed
Description
Description
Hi All,
The MSVC team regularly builds JSON to detect the regressions in the compiler, recently we updated JSON source code to the latest and found this issue. In addition, the issue was not reproduced after adding the /permisisve-.
Reproduction steps
- Open VS2026 x64 Native tools command prompt
 - git clone https://github.com/nlohmann/json.git C:\gitP\nlohmann\json
 - mkdir C:\gitP\nlohmann\json\build_amd64 & cd C:\gitP\nlohmann\json\build_amd64
 - cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_SYSTEM_VERSION=10.0.26100.0 -DJSON_BuildTests=On ..
 - msbuild /m /p:Platform=x64 /p:Configuration=Release nlohmann_json.sln /t:Rebuild
 
Expected vs. actual results
Expected build successful.
Minimal code example
The problem occurs with this code:
++
        json j;
        const json::array_t a = j;
        json const j_string = "Path";
        auto p = j_string.template get<nlohmann::detail::std_fs::path>(); // failsError messages
unit-conversions.cpp
C:\gitP\nlohmann\json\tests\src\unit-conversions.cpp(1667): error C2672: 'nlohmann::json_abi_v3_12_0::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::json_abi_v3_12_0::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>,void>::get': no matching overloaded function found
C:\gitP\nlohmann\json\include\nlohmann/json.hpp(1813): note: could be 'unknown-type nlohmann::json_abi_v3_12_0::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::json_abi_v3_12_0::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>,void>::get(void) noexcept'
C:\gitP\nlohmann\json\tests\src\unit-conversions.cpp(1667): note: 'unknown-type nlohmann::json_abi_v3_12_0::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::json_abi_v3_12_0::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>,void>::get(void) noexcept': could not deduce template argument for '__formal'
C:\gitP\nlohmann\json\include\nlohmann/json.hpp(1812): note: 'type': is not a member of any direct or indirect base class of 'std::enable_if<false,int>'
C:\gitP\nlohmann\json\include\nlohmann/json.hpp(1772): note: or       'unknown-type nlohmann::json_abi_v3_12_0::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::json_abi_v3_12_0::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>,void>::get(void) noexcept(<expr>) const'
C:\gitP\nlohmann\json\tests\src\unit-conversions.cpp(1667): note: Failed to specialize function template 'unknown-type nlohmann::json_abi_v3_12_0::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::json_abi_v3_12_0::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>,void>::get(void) noexcept(<expr>) const'
C:\gitP\nlohmann\json\tests\src\unit-conversions.cpp(1667): note: With the following template arguments:
C:\gitP\nlohmann\json\tests\src\unit-conversions.cpp(1667): note: 'ValueTypeCV=std::filesystem::path'
C:\gitP\nlohmann\json\tests\src\unit-conversions.cpp(1667): note: 'ValueType=std::filesystem::path'
C:\gitP\nlohmann\json\include\nlohmann/json.hpp(1774): note: 'nlohmann::json_abi_v3_12_0::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::json_abi_v3_12_0::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>,void>::get_impl': no matching overloaded function found
C:\gitP\nlohmann\json\include\nlohmann/json.hpp(1737): note: could be 'unknown-type nlohmann::json_abi_v3_12_0::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::json_abi_v3_12_0::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>,void>::get_impl(nlohmann::json_abi_v3_12_0::detail::priority_tag<4>) noexcept const'
C:\gitP\nlohmann\json\include\nlohmann/json.hpp(1724): note: or       'nlohmann::json_abi_v3_12_0::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::json_abi_v3_12_0::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>,void> nlohmann::json_abi_v3_12_0::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::json_abi_v3_12_0::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>,void>::get_impl(nlohmann::json_abi_v3_12_0::detail::priority_tag<3>) const'
C:\gitP\nlohmann\json\include\nlohmann/json.hpp(1701): note: or       'BasicJsonType nlohmann::json_abi_v3_12_0::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::json_abi_v3_12_0::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>,void>::get_impl(nlohmann::json_abi_v3_12_0::detail::priority_tag<2>) const'
C:\gitP\nlohmann\json\include\nlohmann/json.hpp(1676): note: or       'ValueType nlohmann::json_abi_v3_12_0::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::json_abi_v3_12_0::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>,void>::get_impl(nlohmann::json_abi_v3_12_0::detail::priority_tag<1>) noexcept(<expr>) const'
C:\gitP\nlohmann\json\include\nlohmann/json.hpp(1634): note: or       'ValueType nlohmann::json_abi_v3_12_0::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::json_abi_v3_12_0::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>,void>::get_impl(nlohmann::json_abi_v3_12_0::detail::priority_tag<0>) noexcept(<expr>) const'
C:\gitP\nlohmann\json\tests\src\unit-conversions.cpp(1668): error C3536: 'p': cannot be used before it is initializedCompiler and operating system
VS2026
Library version
Validation
-  The bug also occurs if the latest version from the 
developbranch is used. - I can successfully compile and run the unit tests.
 
Metadata
Metadata
Assignees
Labels
kind: bugplatform: visual studiorelated to MSVCrelated to MSVCstate: help neededthe issue needs help to proceedthe issue needs help to proceed