Commit a3606d7 1 parent aec09a4 commit a3606d7 Copy full SHA for a3606d7
File tree 1 file changed +21
-0
lines changed
tests/ui/precondition-checks
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Test that none of the precondition checks panic on zero-sized reads or writes through null.
2
+
3
+ //@ run-pass
4
+ //@ compile-flags: -Zmir-opt-level=0 -Copt-level=0 -Cdebug-assertions=yes
5
+
6
+ use std:: ptr;
7
+
8
+ fn main ( ) {
9
+ unsafe {
10
+ ptr:: copy_nonoverlapping :: < u8 > ( ptr:: null ( ) , ptr:: null_mut ( ) , 0 ) ;
11
+ ptr:: copy_nonoverlapping :: < ( ) > ( ptr:: null ( ) , ptr:: null_mut ( ) , 123 ) ;
12
+ ptr:: copy :: < u8 > ( ptr:: null ( ) , ptr:: null_mut ( ) , 0 ) ;
13
+ ptr:: copy :: < ( ) > ( ptr:: null ( ) , ptr:: null_mut ( ) , 123 ) ;
14
+ ptr:: swap :: < ( ) > ( ptr:: null_mut ( ) , ptr:: null_mut ( ) ) ;
15
+ ptr:: replace :: < ( ) > ( ptr:: null_mut ( ) , ( ) ) ;
16
+ ptr:: read :: < ( ) > ( ptr:: null ( ) ) ;
17
+ ptr:: write :: < ( ) > ( ptr:: null_mut ( ) , ( ) ) ;
18
+ ptr:: read_volatile :: < ( ) > ( ptr:: null ( ) ) ;
19
+ ptr:: write_volatile :: < ( ) > ( ptr:: null_mut ( ) , ( ) ) ;
20
+ }
21
+ }
You can’t perform that action at this time.
0 commit comments