Merge pull request #503 from RalfJung/atomic-arith

Reject atomic arithmetic on non-integer types
This commit is contained in:
Ralf Jung
2018-10-31 13:02:37 +01:00
committed by GitHub
2 changed files with 12 additions and 0 deletions
+3
View File
@@ -126,6 +126,9 @@ fn call_intrinsic(
"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
@@ -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
}
}