-
Notifications
You must be signed in to change notification settings - Fork 516
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
Statement::bind truncates long integer to 32 bits on x86_64 Linux #155
Comments
Woa, thanks for diging into this, and reporting it so clearly! I bet this particular case is not on my unit test suite :( I am away from my computer, but I will look into this asap |
So I easily reproduced the problem with a dedicated unit test using your code sample. Then I fixed the bug by adding the appropriate include as you stated. Thanks again @tszypenbejl for the clear analysis and the fix. |
Thank you for taking care of the problem @SRombauts . I did a |
Thank you again |
…n x86_64 Linux Reproduced the problem with a dedicated unit test, then fixed the bug. Thanks @tszypenbejl for the clear analysis and the fix.
Binding long values (which are 64-bit on x86_64 Linux) to a statement yields a surprising result.
Here is a minimal program to reproduce the problem:
The value bound to the query in this example program is 2^32+1. However, if you build and run the program on x86_64 Linux, you will see that the output of the program is '1' instead of the expected '4294967297'.
Uncommenting the first line (
#include <climits>
) makes the program behave as expected.The easiest way to fix the bug would probably be to include the climits header in SQLiteCpp/Statement.h (climits provides definitions of LONG_MAX and INT_MAX which are used in some preprocessor directives in that file).
The text was updated successfully, but these errors were encountered: