-
Notifications
You must be signed in to change notification settings - Fork 13.4k
signed division has undefined behaviour on overflow #8460
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
@thestinger what needs to be done for this? Check for certain numbers when dividing and fail!() if it would trigger UB? |
@cmr: signed division should check |
So this check happens in trans, |
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
Jun 6, 2014
Division and remainder by 0 are undefined behavior, and are detected at runtime. This commit adds support for ensuring that MIN / -1 is also checked for at runtime, as this would cause signed overflow, or undefined behvaior. Closes rust-lang#8460
mcpherrinm
pushed a commit
to mcpherrinm/rust
that referenced
this issue
Jun 10, 2014
Division and remainder by 0 are undefined behavior, and are detected at runtime. This commit adds support for ensuring that MIN / -1 is also checked for at runtime, as this would cause signed overflow, or undefined behvaior. Closes rust-lang#8460
15 tasks
flip1995
pushed a commit
to flip1995/rust
that referenced
this issue
Feb 24, 2022
…nishearth False positive redundant_closure when using ref pattern in closure params fixes rust-lang#8460 Fixed [redundant_closure] so that closures of which params bound as `ref` or `ref mut ` doesn't trigger the lint. (e.g. `|ref x| some_expr` doesn't trigger the lint.) changelog: none
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
http://llvm.org/docs/LangRef.html#sdiv-instruction
Note that this is undefined behaviour, not just an unspecified result like a shift by too many bits. We need to add a check for this.
The text was updated successfully, but these errors were encountered: