Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation fails in MSVC with the Microsoft Language Extensions disabled #1481

Closed
Zalez95 opened this issue Feb 13, 2019 · 4 comments
Closed
Labels
platform: visual studio related to MSVC solution: wontfix the issue will not be fixed (either it is impossible or deemed out of scope)

Comments

@Zalez95
Copy link

Zalez95 commented Feb 13, 2019

  • What is the issue you have?
    I can't compile my project in Windows with Visual Studio with the /Za flag (Disable Language Extensions) enabled. This flag is used to ensure C++11 conformance.
    The errors that the compiler is giving to me are the following:
<path>\build\ext\nlohmann-json\include\nlohmann\detail\output\serializer.hpp(453): error C2672: 'nlohmann::detail::binary_writer<BasicJsonType,char>::to_char_type': no matching overloaded function found
        with
        [
            BasicJsonType=nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>
        ]
<path>\build\ext\nlohmann-json\include\nlohmann\detail\output\serializer.hpp(299): note: while compiling class template member function 'void nlohmann::detail::serializer<nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>>::dump_escaped(const std::basic_string<char,std::char_traits<char>,std::allocator<char>> &,const bool)'
<path>\build\ext\nlohmann-json\include\nlohmann\detail\output\serializer.hpp(123): note: see reference to function template instantiation 'void nlohmann::detail::serializer<nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>>::dump_escaped(const std::basic_string<char,std::char_traits<char>,std::allocator<char>> &,const bool)' being compiled
<path>\build\ext\nlohmann-json\include\nlohmann\json.hpp(1966): note: see reference to class template instantiation 'nlohmann::detail::serializer<nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>>' being compiled
<path>\build\ext\nlohmann-json\include\nlohmann\json.hpp(1966): note: while compiling class template member function 'std::basic_string<char,std::char_traits<char>,std::allocator<char>> nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>::dump(const int,const char,const bool,const nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>::error_handler_t) const'
<path>\build\ext\nlohmann-json\include\nlohmann\json.hpp(7928): note: see reference to function template instantiation 'std::basic_string<char,std::char_traits<char>,std::allocator<char>> nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>::dump(const int,const char,const bool,const nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>::error_handler_t) const' being compiled
<path>\build\ext\nlohmann-json\include\nlohmann\json.hpp(7927): note: see reference to class template instantiation 'nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>' being compiled
<path>\build\ext\nlohmann-json\include\nlohmann\detail\output\serializer.hpp(453): error C2783: 'CharType nlohmann::detail::binary_writer<BasicJsonType,CharType>::to_char_type(uint8_t) noexcept': could not deduce template argument for '__formal'
        with
        [
            CharType=char,
            BasicJsonType=nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>
        ]
<path>\build\ext\nlohmann-json\include\nlohmann\detail\output\binary_writer.hpp(1297): note: see declaration of 'nlohmann::detail::binary_writer<BasicJsonType,char>::to_char_type'
        with
        [
            BasicJsonType=nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>
        ]
<path>\build\ext\nlohmann-json\include\nlohmann\detail\output\serializer.hpp(454): error C2672: 'nlohmann::detail::binary_writer<BasicJsonType,char>::to_char_type': no matching overloaded function found
        with
        [
            BasicJsonType=nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>
        ]
<path>\build\ext\nlohmann-json\include\nlohmann\detail\output\serializer.hpp(454): error C2783: 'CharType nlohmann::detail::binary_writer<BasicJsonType,CharType>::to_char_type(uint8_t) noexcept': could not deduce template argument for '__formal'
        with
        [
            CharType=char,
            BasicJsonType=nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>
        ]
<path>\build\ext\nlohmann-json\include\nlohmann\detail\output\binary_writer.hpp(1297): note: see declaration of 'nlohmann::detail::binary_writer<BasicJsonType,char>::to_char_type'
        with
        [
            BasicJsonType=nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>
        ]
<path>\build\ext\nlohmann-json\include\nlohmann\detail\output\serializer.hpp(455): error C2672: 'nlohmann::detail::binary_writer<BasicJsonType,char>::to_char_type': no matching overloaded function found
        with
        [
            BasicJsonType=nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>
        ]
<path>\build\ext\nlohmann-json\include\nlohmann\detail\output\serializer.hpp(455): error C2783: 'CharType nlohmann::detail::binary_writer<BasicJsonType,CharType>::to_char_type(uint8_t) noexcept': could not deduce template argument for '__formal'
        with
        [
            CharType=char,
            BasicJsonType=nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>
        ]
<path>\build\ext\nlohmann-json\include\nlohmann\detail\output\binary_writer.hpp(1297): note: see declaration of 'nlohmann::detail::binary_writer<BasicJsonType,char>::to_char_type'
        with
        [
            BasicJsonType=nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>
        ]
  • Please describe the steps to reproduce the issue. Can you provide a small but working code example?
    In CMake i've added the following compile options:
    target_compile_options(Test PRIVATE /Za /W4 -D_CRT_SECURE_NO_WARNINGS)

  • Which compiler and operating system are you using?
    I'm compiling in Windows 10 64 bits with Visual Studio 15 (2017) and MSVC 19.16.27026.1 for x64.

  • Did you use a released version of the library or the version from the develop branch?
    I've tried both, the develop single include file that is referenced in the README and I've also downloaded the tag v3.5.0 and included the library as a dependency with CMake, and neither worked.

  • If you experience a compilation error: can you compile and run the unit tests?
    Yes, I've compiled them without any problems

@nlohmann nlohmann added the platform: visual studio related to MSVC label Feb 15, 2019
@nickaein
Copy link
Contributor

This official blog post says that /Za is stalled and not recommended for newer projects (look under Is there any relation to /Za?). Have you tried using /permissive- instead?

It seems in presence of /Za flag the compiler has issues in understanding SFINAE . Considering that support for SFINAE has been recently added to VC++ versions, there is possibility that /Za incorrectly disables this support since it has not been updated.

I might be wrong though as /Za documentation doesn't mention its deprecation. The issue https://github.com/MicrosoftDocs/cpp-docs/issues/801 will hopefully clears this up.

@nlohmann
Copy link
Owner

The linked references give me the impression that this issue won't be fixed.

@nlohmann nlohmann added the solution: wontfix the issue will not be fixed (either it is impossible or deemed out of scope) label Feb 22, 2019
@nlohmann
Copy link
Owner

Thanks @nickaein for the research! @Zalez95 can I close the issue?

@Zalez95
Copy link
Author

Zalez95 commented Feb 22, 2019

Yes, of course. Thanks to everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: visual studio related to MSVC solution: wontfix the issue will not be fixed (either it is impossible or deemed out of scope)
Projects
None yet
Development

No branches or pull requests

3 participants