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
{{ message }}
Repository navigation
No exception raised for Out Of Range input of numbers #647
The first number is parsed as double and the second as uint64_t. Calling get does not check for overflows - it is just like writing int i = 12345678901235.1235567.
In fact, Xcode's undefined behavior sanitizer detects the first issue:
/Users/niels/Documents/development/debug_lexer/debug_lexer/json.hpp:949:23: runtime error: 1.84467e+19 is outside the range of representable values of type 'unsigned long long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/niels/Documents/development/debug_lexer/debug_lexer/json.hpp:949:23 in
However, this is not inside the library, but in the requested conversion from double to unsigned long long. I'm not sure whether adding runtime checks to the library would be helpful here.
Activity
nlohmann commentedon Jul 5, 2017
The first number is parsed as double and the second as uint64_t. Calling get does not check for overflows - it is just like writing
int i = 12345678901235.1235567.nlohmann commentedon Jul 5, 2017
Remark: an exception is thrown by the parser if the given number does not fit neither the integer types nor the floating-point type.
nlohmann commentedon Jul 6, 2017
Did this answer your question?
nlohmann commentedon Jul 8, 2017
In fact, Xcode's undefined behavior sanitizer detects the first issue:
However, this is not inside the library, but in the requested conversion from
doubletounsigned long long. I'm not sure whether adding runtime checks to the library would be helpful here.