Error in dump() with int64_t minimum value #1708
Labels
kind: bug
release item: 🐛 bug fix
solution: proposed fix
a fix for the issue has been proposed and waits for confirmation
Milestone
What is the issue you have?
There is a segfault when calling
dump()
on annlohmann::json
node containing anint64_t
value set tostd::numeric_limits<int64_t>::min()
. Any otherint64_t
value (for example, the minimum value + 1, or the maximum value) seems to work fine. Other int or double values (uint64_t
, for example) also seem to have no issues.Please describe the steps to reproduce the issue. Can you provide a small but working code example?
For this example, the the entire nlohmann JSON repo is included in the folder
json
.main.cpp:
Makefile:
What is the expected behavior?
Calling
dump()
returns a string version of the value.And what is the actual behavior instead?
See above. The error code is:
In gdb:
The expected output is:
Which compiler and operating system are you using? Is it a supported compiler?
All of this is on the same Ubuntu 16.04 machine. The issue occurs when compiling g++-5 (
(Ubuntu 5.5.0-12ubuntu1~16.04) 5.5.0 20171010
) for C++11, C++14, or C++17. The issue only occurs when compiling with -O2 or higher. Both g++-6 ((Ubuntu 6.5.0-2ubuntu1~16.04) 6.5.0 20181026
) and g++-7 ((Ubuntu 7.4.0-1ubuntu1~16.04~ppa1) 7.4.0
) compile and run with no issues across all optimization levels.Did you use a released version of the library or the version from the
develop
branch?Tried with the
develop
branch as well as versions 3.6.1 and 3.7.0. The behavior was the same in all cases.If you experience a compilation error: can you compile and run the unit tests?
There were no compilation errors. All tests passed.
Notes
The issue might be caused by line 14267 of
json.hpp
on thedevelop
branch (https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json.hpp#L14267).The text was updated successfully, but these errors were encountered: