File tree 2 files changed +17
-1
lines changed
2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,16 @@ const FOO: *const u32 = { //~ ERROR it is undefined behavior
3
3
& x
4
4
} ;
5
5
6
+ union Union {
7
+ ptr : * const u32
8
+ }
9
+
10
+ const BAR : Union = { //~ ERROR encountered dangling pointer in final value
11
+ let x = 42 ;
12
+ Union { ptr : & x }
13
+ } ;
14
+
6
15
fn main ( ) {
7
16
let x = FOO ;
17
+ let x = BAR ;
8
18
}
Original file line number Diff line number Diff line change @@ -9,6 +9,12 @@ LL | const FOO: *const u32 = {
9
9
╾ALLOC0<imm>╼ │ ╾──────╼
10
10
}
11
11
12
- error: aborting due to 1 previous error
12
+ error: encountered dangling pointer in final value of constant
13
+ --> $DIR/dangling_raw_ptr.rs:10:1
14
+ |
15
+ LL | const BAR: Union = {
16
+ | ^^^^^^^^^^^^^^^^
17
+
18
+ error: aborting due to 2 previous errors
13
19
14
20
For more information about this error, try `rustc --explain E0080`.
You can’t perform that action at this time.
0 commit comments