Add overflow_check check

This commit is contained in:
Yuki Okushi 2019-09-02 02:18:16 +09:00
parent 3a6aadaa8c
commit 4a0872b37e
2 changed files with 6 additions and 8 deletions

View File

@ -405,11 +405,13 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
}
let arg = self.eval_operand(arg, source_info)?;
let is_release_mode = self.tcx.sess.opts.debugging_opts.mir_opt_level >= 2;
let is_release_mode = self.tcx.sess.overflow_checks();
let val = self.use_ecx(source_info, |this| {
let prim = this.ecx.read_immediate(arg)?;
match op {
UnOp::Neg => {
// We don't have to check overflow here when we already
// check it in release mode.
if is_release_mode
&& prim.to_bits()? == (1 << (prim.layout.size.bits() - 1)) {
throw_panic!(OverflowNeg)
@ -485,7 +487,9 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
Scalar::from_bool(overflow).into(),
)
} else {
if self.tcx.sess.opts.debugging_opts.mir_opt_level >= 2 && overflow {
// We don't have to check overflow here when we already
// check it in release mode.
if self.tcx.sess.overflow_checks() && overflow {
let err = err_panic!(Overflow(op)).into();
let _: Option<()> = self.use_ecx(source_info, |_| Err(err));
return None;

View File

@ -1,6 +0,0 @@
error: failed to remove $TEST_BUILD_DIR/issues/issue-8171-default-method-self-inherit-builtin-trait/issue-8171-default-method-self-inherit-builtin-trait.issue_8171_default_method_self_inherit_builtin_trait.7rcbfp3g-cgu.0.rcgu.o: 指定されたパスが見つかりません。 (os error 3)
error: failed to remove $TEST_BUILD_DIR/issues/issue-8171-default-method-self-inherit-builtin-trait/issue-8171-default-method-self-inherit-builtin-trait.issue_8171_default_method_self_inherit_builtin_trait.7rcbfp3g-cgu.1.rcgu.o: 指定されたパスが見つかりません。 (os error 3)
error: aborting due to 2 previous errors