-
Notifications
You must be signed in to change notification settings - Fork 3
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
Assert failure with compile optimizations #1
Comments
Hello, nisen |
Hello, nisen |
Hey sorry, |
I believe I found the real problem and it is quite interesting see this link bellow if you want more information https://www.embeddeduse.com/2013/08/25/casting-a-negative-float-to-an-unsigned-int/ So basically I think the compiler is doing an implicit double cast float -> int -> unsigned int. But with optimization activated it is doing float -> unsigned int directly thus skipping the int cast resulting in an 0 being inserted when value is inferior to -1 as stated in the article. I am not 100% sure but this is my best guess. So volatile keyword is now removed and instead I put a cast to int before uint64_t. |
Thanks for sharing the article. It is really interesting, Sometimes casting can be a real thieve of time. At the moment I have no time to look at the problem in the code, but it sounds like a possible cause. |
If you compile the tests with
gcc -g -Wall -Wextra -pedantic-errors tests/tests.c -o bin/tests -O3
you get the error message
The error occurs at optimization levels 1-3 and s (size optimization).
The text was updated successfully, but these errors were encountered: