summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/copy-prop/issue_107511.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/mir-opt/copy-prop/issue_107511.rs')
-rw-r--r--tests/mir-opt/copy-prop/issue_107511.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/mir-opt/copy-prop/issue_107511.rs b/tests/mir-opt/copy-prop/issue_107511.rs
new file mode 100644
index 000000000..d593f2872
--- /dev/null
+++ b/tests/mir-opt/copy-prop/issue_107511.rs
@@ -0,0 +1,13 @@
+// unit-test: CopyProp
+
+// EMIT_MIR issue_107511.main.CopyProp.diff
+fn main() {
+ let mut sum = 0;
+ let a = [0, 10, 20, 30];
+
+ // `i` is assigned in a loop. Only removing its `StorageDead` would mean that
+ // execution sees repeated `StorageLive`. This would be UB.
+ for i in 0..a.len() {
+ sum += a[i];
+ }
+}