Skip to content
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

Warn about -fsanitize=integer for unsigned integers #19

Closed
rben-dev opened this issue Sep 2, 2021 · 1 comment
Closed

Warn about -fsanitize=integer for unsigned integers #19

rben-dev opened this issue Sep 2, 2021 · 1 comment

Comments

@rben-dev
Copy link

rben-dev commented Sep 2, 2021

First of all, great work! Thanks for compiling all this very useful information :-)

Regarding clang's -fsanitize=integer option, the sanitizer might be a little picky when it comes to unsigned integers arithmetic and left shift operations. According to 6.2.5.9 of ISO C99, unsigned integers "can never overflow" (https://frama-c.com/download/frama-c-rte-manual.pdf), while the sanitizer will trigger a "runtime error" whenever a left shift on an unsigned integer will overflow a primitive unsigned integer type size or when an arithmetic operation does so. Nonetheless, such operations are quite common e.g. when developing big int or cryptographic libraries.

It might be useful to document the ways of deactivating explicitly such errors (especially if the integer sanitizer is used for production) while keeping the other undefined behaviors using -fno-sanitize=unsigned-integer-overflow -fno-sanitize=unsigned-shift-base.

Regards,

@trou trou closed this as completed in 16ccb19 Sep 7, 2021
@trou
Copy link
Collaborator

trou commented Sep 7, 2021

Thanks for the report! I've actually suggested using attributes to limit the deactivation to specific functions, rather than globally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants