]> git.lizzy.rs Git - rust.git/commitdiff
Add test for comparing ptrs into different allocs.
authorScott Olson <scott@solson.me>
Wed, 6 Apr 2016 10:24:35 +0000 (04:24 -0600)
committerScott Olson <scott@solson.me>
Wed, 6 Apr 2016 10:24:35 +0000 (04:24 -0600)
test/errors.rs

index 1b0401bb9cc241154aded0f3657eaf470f3cd6ec..8faff149167e9ba3071d4585333ad99f76160a19 100755 (executable)
@@ -3,10 +3,17 @@
 
 #[miri_run]
 fn overwriting_part_of_relocation_makes_the_rest_undefined() -> i32 {
-    let mut p: *const i32 = &42;
+    let mut p = &42;
     unsafe {
-        let ptr = &mut p as *mut *const i32 as *mut u32;
-        *ptr = 123;
-        *p
+        let ptr: *mut _ = &mut p;
+        *(ptr as *mut u32) = 123;
     }
+    *p
+}
+
+#[miri_run]
+fn pointers_to_different_allocations_are_unorderable() -> bool {
+    let x: *const u8 = &1;
+    let y: *const u8 = &2;
+    x < y
 }