summaryrefslogtreecommitdiffstats
path: root/tests/ui/consts/const-eval/ub-slice-get-unchecked.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/consts/const-eval/ub-slice-get-unchecked.rs')
-rw-r--r--tests/ui/consts/const-eval/ub-slice-get-unchecked.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/ui/consts/const-eval/ub-slice-get-unchecked.rs b/tests/ui/consts/const-eval/ub-slice-get-unchecked.rs
new file mode 100644
index 000000000..d9a74b4f3
--- /dev/null
+++ b/tests/ui/consts/const-eval/ub-slice-get-unchecked.rs
@@ -0,0 +1,9 @@
+#![feature(const_slice_index)]
+
+const A: [(); 5] = [(), (), (), (), ()];
+
+// Since the indexing is on a ZST, the addresses are all fine,
+// but we should still catch the bad range.
+const B: &[()] = unsafe { A.get_unchecked(3..1) };
+
+fn main() {}