You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A code analysis warning is reported for string_concat.hpp line 141.
##[warning]Include\nlohmann\detail\string_concat.hpp(141,0): Warning C26800: Use of a moved from object: ''(*<args_2>)'' (lifetime.1).
As far as I understand, the issue seems to be that std::forward is used two times here.
It could be possible that the concat_length function moves the "args", and then they would be empty for the call on line 141.
I think the concat_length function does not need a forwarding reference, as you never want to "move" there.
So i think changing it to something like this would fix it:
@falbrechtskirchinger Agreed, don't see any reason to accept rvalue references in concat_length, nothing is moved from, plain references should be fine.
Description
A code analysis warning is reported for string_concat.hpp line 141.
##[warning]Include\nlohmann\detail\string_concat.hpp(141,0): Warning C26800: Use of a moved from object: ''(*<args_2>)'' (lifetime.1).
json/include/nlohmann/detail/string_concat.hpp
Lines 136 to 143 in a3e6e26
As far as I understand, the issue seems to be that std::forward is used two times here.
It could be possible that the concat_length function moves the "args", and then they would be empty for the call on line 141.
Possible solution:
json/include/nlohmann/detail/string_concat.hpp
Lines 30 to 31 in a3e6e26
I think the concat_length function does not need a forwarding reference, as you never want to "move" there.
So i think changing it to something like this would fix it:
template<typename StringType, typename... Args>
inline std::size_t concat_length(const StringType& str, const Args& ... rest);
And then simply drop the std::forward on the call.
Reproduction steps
Do a Code Analysis build with MSVC 17.3 and use "Microsoft Native Recommended Rules"
Expected vs. actual results
No code analysis warning
Minimal code example
No response
Error messages
##[warning]Include\nlohmann\detail\string_concat.hpp(141,0): Warning C26800: Use of a moved from object: ''(*<args_2>)'' (lifetime.1).
Compiler and operating system
Win10; MSVC 17.3 (v143 platform toolset); c++ language standard: /std:c++latest
Library version
3.11.2 (include version)
Validation
develop
branch is used.The text was updated successfully, but these errors were encountered: