nlohmann / json

JSON for Modern C++
https://json.nlohmann.me
MIT License
42.4k stars 6.67k forks source link

Compiling in visual studio 2022 gives a warning #4081

Closed LordWolfenstein closed 1 year ago

LordWolfenstein commented 1 year ago

Description

I have installed version 3.11.2 with the nuget packet manager in Visual Studio 2022 Community edition. When I compile I get this error in json.hpp.

image

Reproduction steps

Create new C++ console application in Visual Studio and install it with nuget. Include json.hpp in your main file and use it somehow. Have the json.hpp file open in the editor. Compile.

Expected vs. actual results

I expect no no warning but I get warnings.

Minimal code example

#include <nlohmann/json.hpp>

int main()
{
    nlohmann::json data;
}

Error messages

Severity    Code    Description Project File    Line    Suppression State
Warning C26800  Use of a moved from object: ''(*<args_1>)'' (lifetime.1).   Sandbox D:\Visual Studio 2022\Test\packages\nlohmann.json.3.11.2\build\native\include\nlohmann\json.hpp 4281

Compiler and operating system

Windows 10 and Visual Studio Community 2022 Version 17.6.5 VisualStudio.17.Release/17.6.5+33829.357

Library version

3.11.2

Validation

boatwrong commented 1 year ago

I've got the minimal example working in both VS2019 and VS2022. Since it's a warning, are you able to run the program?

I'm new to using this library but am implementing it in a console app through VS2019 with success. However, instead of using the NuGet package I cloned the repo and copied the json.hpp from the json/single_include/nlohmann directory into my project.

EDIT: I should also specify this was one on a Windows 10 machine.

LordWolfenstein commented 1 year ago

This is only a warning for me to. I have been able to execute without problems so far.

gregmarr commented 1 year ago

This was fixed in December. https://github.com/nlohmann/json/pull/3889