]> git.lizzy.rs Git - rust.git/commit
rustc: Avoid UB with signed division/remainder
authorAlex Crichton <alex@alexcrichton.com>
Thu, 5 Jun 2014 19:23:34 +0000 (12:23 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Sat, 7 Jun 2014 02:51:13 +0000 (19:51 -0700)
commitf35328caed68528380cf5f19e4c04eba70f03638
treeb84e254f133ab642f0a935be3366bc9e06c0bb57
parent9fd075f5af12afe91a6be7398cfc85b2903c28bb
rustc: Avoid UB with signed division/remainder

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 #8460
src/librustc/middle/trans/base.rs
src/librustc/middle/trans/expr.rs
src/test/run-pass/issue-8460.rs [new file with mode: 0644]