Skip to content

[MSVC][build] JSON failed with error C2672: 'nlohmann::json_abi_v3_12_0::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double, #4974

@QuellaZhang

Description

@QuellaZhang

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-.

Build.log

Reproduction steps

  1. Open VS2026 x64 Native tools command prompt
  2. git clone https://github.com/nlohmann/json.git C:\gitP\nlohmann\json
  3. mkdir C:\gitP\nlohmann\json\build_amd64 & cd C:\gitP\nlohmann\json\build_amd64
  4. cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_SYSTEM_VERSION=10.0.26100.0 -DJSON_BuildTests=On ..
  5. 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>(); // fails

Error 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 initialized

Compiler and operating system

VS2026

Library version

3ed64e5

Validation

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions