Skip to content

Commit 71bb5cd

Browse files
committed
Add test case which demonstrates current miscomp.
1 parent 1389494 commit 71bb5cd

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/test/ui/mir/issue67529.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Tests for miscompilation due to const propagation, as described in #67529. This used to result
2+
// in an assertion error, because d.a was replaced with a new allocation that was never
3+
// initialized.
4+
//
5+
// run-pass
6+
// compile-flags: -Zmir-opt-level=2
7+
struct Baz<T: ?Sized> {
8+
a: T,
9+
}
10+
11+
fn main() {
12+
let d: Baz<[i32; 4]> = Baz { a: [1, 2, 3, 4] };
13+
assert_eq!([1, 2, 3, 4], d.a);
14+
}

0 commit comments

Comments
 (0)