File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
Expand file tree Collapse file tree 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
33 & x
44} ;
55
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+
615fn main ( ) {
716 let x = FOO ;
17+ let x = BAR ;
818}
Original file line number Diff line number Diff line change @@ -9,6 +9,12 @@ LL | const FOO: *const u32 = {
99 ╾ALLOC0<imm>╼ │ ╾──────╼
1010 }
1111
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
1319
1420For more information about this error, try `rustc --explain E0080`.
You can’t perform that action at this time.
0 commit comments