-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Unexpected conversion from 'true'/'false' to some integer types #4358
Comments
I am having the same issue and apologies if I am not understanding this correctly as I am new to C++ and have only just started using this library, but it looks like the integer value is not being considered a basic_json and so is calling the explicit cast from_json. At least the comment above the function leads me to believe this. |
Description
Converting from
"value": true
or"value": false
behaves unexpectedly and differently for certain integer types.I was expecting all conversions from a boolean true/false to integer value to fail, however it is stored as a 1 or 0.
Reproduction steps
Given:
This will result in a
1
invalue
.Using
uint64_t
will throw atype_error
.Expected vs. actual results
I expected all boolean to integer conversions to fail. Instead a
true
->1
andfalse
->0
for certain integer values.Various integer conversions - https://godbolt.org/z/7Wrh6EanW
The
uint64_t
case is taking the path throughget_arithmetic_value
The
int
case is taking the path throughMinimal code example
https://godbolt.org/z/fs4frqz7G
Error messages
No response
Compiler and operating system
Latest MSVC & Clang
Library version
3.11.3
Validation
develop
branch is used.The text was updated successfully, but these errors were encountered: