Reject atomic arithmetic on non-integer types

Fixes #181
This commit is contained in:
Ralf Jung 2018-10-31 11:04:35 +01:00
parent f0c1f18314
commit 40b7502613
2 changed files with 12 additions and 0 deletions

View File

@ -126,6 +126,9 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'a, 'mir, '
"atomic_xsub_acqrel" |
"atomic_xsub_relaxed" => {
let ptr = self.ref_to_mplace(self.read_value(args[0])?)?;
if !ptr.layout.ty.is_integral() {
return err!(Unimplemented(format!("Atomic arithmetic operations only work on integer types")));
}
let rhs = self.read_value(args[1])?;
let old = self.read_value(ptr.into())?;
self.write_value(*old, dest)?; // old value is returned

View File

@ -0,0 +1,9 @@
#![feature(core_intrinsics)]
pub fn main() {
let mut z: f64 = 1.0;
unsafe {
::std::intrinsics::atomic_xadd(&mut z, 2.0);
//~^ ERROR: Atomic arithmetic operations only work on integer types
}
}