microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
23.27k stars 6.42k forks source link

json-schema-validator build failure #31648

Closed mark-99 closed 1 year ago

mark-99 commented 1 year ago

Operating system

Windows

Compiler

MSVC /c++:latest

Steps to reproduce the behavior

Breaks after updating to VS 17.6.2.
Updated vcpkg to latest but it didn't help.

Error seems to be in nlohmann, although we use that separately and it's ok (maybe embedded version is old?).

Failure logs

Using source at C:/Temp/MdpCpp/vcpkg/buildtrees/json-schema-validator/src/2.2.0-e87f98a2b7.clean
 C:\Temp\MdpCpp\vcpkg\buildtrees\json-schema-validator\src\2.2.0-e87f98a2b7.clean\src\json-validator.cpp(606): error C7692: '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>>>::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>>> &) noexcept const': rewritten candidate function was excluded from overload resolution because a corresponding operator!= declared in the same scope

Additional context

No response

mark-99 commented 1 year ago

/c++20 is the same, so it's not just C++23 mode.

FrankXie05 commented 1 year ago

It seems that in the new version, operator== and operator!= has been deprecated . Please use teh latest version and try again. vcpkg has updated the version. :)

https://github.com/nlohmann/json/releases/tag/v3.11.2#:~:text=%F0%9F%94%A5,.%20%233684

mark-99 commented 1 year ago

This isn't fixed, I already have latest and have pulled again today (2023-05-30), the failing build is already at v3.11.2

C:\Temp\MdpCpp\out\build\x64-debug-clang\vcpkg_installed\x64-windows-cpp20\include\nlohmann/json.hpp(162): note: see declaration of 'nlohmann::json_abi_v3_11_2::json_pointer<StringType>'

Note json_abi_v3_11_2 It's not clear if nlohmann-json is failing independently or only as a dependency when building json-schema-validator. I'd strongly suspect the latter given nlohmann is widely used but json-schema-validator is more niche. It looks like json-schema-validator is using the deprecated functionality, on the operator== here (json-validator.cpp:606):

            case json::value_t::array: // "type": ["type1", "type2"]
                for (auto &schema_type : attr.value())
                    for (auto &t : schema_types)
                        if (t.first == schema_type)
                            type_[static_cast<uint8_t>(t.second)] = type_schema::make(sch, t.second, root, uris, known_keywords);
                break;
github-actions[bot] commented 1 year ago

This is an automated message. Per our repo policy, stale issues get closed if there has been no activity in the past 28 days. The issue will be automatically closed in 14 days. If you wish to keep this issue open, please add a new comment.

marcodsantia commented 1 year ago

Same issue for me. It works fine when installing json-schema-validator standalone without vcpkg (still using vcpkg for nlohmann_json)

github-actions[bot] commented 1 year ago

This is an automated message. Per our repo policy, stale issues get closed if there has been no activity in the past 28 days. The issue will be automatically closed in 14 days. If you wish to keep this issue open, please add a new comment.

lufi0401 commented 1 year ago

There's a workaround according to https://github.com/nlohmann/json/issues/3868#issuecomment-1563726354

by adding following to the overlay-triplet:

if(${PORT} MATCHES "json-schema-validator")
    set(VCPKG_CXX_FLAGS ${VCPKG_CXX_FLAGS} "-DJSON_HAS_THREE_WAY_COMPARISON=0")
endif()