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

Visual Studio 2017 15.5 C++17 std::allocator deprecations #872

Closed
Kingston1 opened this issue Dec 13, 2017 · 3 comments
Closed

Visual Studio 2017 15.5 C++17 std::allocator deprecations #872

Kingston1 opened this issue Dec 13, 2017 · 3 comments
Assignees
Labels
platform: visual studio related to MSVC solution: proposed fix a fix for the issue has been proposed and waits for confirmation

Comments

@Kingston1
Copy link

Bug Report

Visual Studio 2017 15.5 update introduced a bunch of deprecation warnings when using C++17 feature set. It's trying to guide to better standards compliance.

  • Reproduction

When compiling a project that uses json.hpp usage of std::allocator destroy() and construct() gets flagged.

warning C4996: 'std::allocator<std::map<StringType,nlohmann::basic_jsonstd::map,std::vector,StringType,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer,std::less,std::allocator<std::pair<const StringType,nlohmann::basic_jsonstd::map,std::vector,StringType,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>>>>::destroy': warning STL4010: Various members of std::allocator are deprecated in C++17. Use std::allocator_traits instead of accessing these members directly. You can define _SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to acknowledge that you have received this warning.

warning C4996: 'std::allocator<std::map<StringType,nlohmann::basic_jsonstd::map,std::vector,StringType,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer,std::less,std::allocator<std::pair<const StringType,nlohmann::basic_jsonstd::map,std::vector,StringType,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>>>>::construct': warning STL4010: Various members of std::allocator are deprecated in C++17. Use std::allocator_traits instead of accessing these members directly. You can define _SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to acknowledge that you have received this warning.

  • What is the expected behavior?

There should be no warnings. Improve allocator usage. I have suppressed the warnings in a local fork of json.hpp and everything still works. But who knows for how long.

  • Which compiler and operating system are you using? Is it a [supported compiler]
    Windows 10 Pro x64
    Visual Studio 2017 15.5.1 professional (perhaps should be supported, I am not sure)

  • Did you use a released version of the library or the version from the develop branch?

Happens on both develop of today and Version 2.1.1

nlohmann added a commit that referenced this issue Dec 13, 2017
These were the remaining direct calls to alloc.
@nlohmann
Copy link
Owner

@Kingston1 Thanks for reporting. I hope that #873 fixes this warning. As I do not use MSVC myself, could you check that branch if the warning disappears?

@nlohmann nlohmann self-assigned this Dec 13, 2017
@nlohmann nlohmann added platform: visual studio related to MSVC solution: proposed fix a fix for the issue has been proposed and waits for confirmation labels Dec 13, 2017
@Kingston1
Copy link
Author

Kingston1 commented Dec 14, 2017

The fix works great.

It works fine back-ported to version 2.1.1 as well.

Thank you for the very fast response. Go ahead and merge.

nlohmann added a commit that referenced this issue Dec 14, 2017
@nlohmann
Copy link
Owner

Thanks for checking!

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: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

No branches or pull requests

2 participants