aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.test/fail_compilation/test22709.d
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gdc.test/fail_compilation/test22709.d')
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/test22709.d29
1 files changed, 29 insertions, 0 deletions
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test22709.d b/gcc/testsuite/gdc.test/fail_compilation/test22709.d
new file mode 100644
index 0000000..dd5258e
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/test22709.d
@@ -0,0 +1,29 @@
+/*
+REQUIRED_ARGS: -preview=dip1000
+TEST_OUTPUT:
+---
+fail_compilation/test22709.d(15): Error: address of variable `local` assigned to `arr` with longer lifetime
+fail_compilation/test22709.d(20): Error: address of variable `local` assigned to `arr` with longer lifetime
+---
+*/
+
+// https://issues.dlang.org/show_bug.cgi?id=22709
+@safe:
+
+void escape(ref ubyte[] arr, ref ubyte[64] local)
+{
+ arr = local[];
+}
+
+void escape1(ref ubyte[64] local, ref ubyte[] arr)
+{
+ arr = local[];
+}
+
+ubyte[] getArr()
+{
+ ubyte[64] blob;
+ ubyte[] arr;
+ escape(arr, blob[]);
+ return arr;
+}