summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--compiler-rt/test/asan/TestCases/use-after-scope-goto.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/compiler-rt/test/asan/TestCases/use-after-scope-goto.c b/compiler-rt/test/asan/TestCases/use-after-scope-goto.c
new file mode 100644
index 00000000000..e69cc718065
--- /dev/null
+++ b/compiler-rt/test/asan/TestCases/use-after-scope-goto.c
@@ -0,0 +1,21 @@
+// RUN: %clang_asan -O0 -fsanitize-address-use-after-scope %s -o %t && %run %t
+
+// Function jumps over variable initialization making lifetime analysis
+// ambiguous. Asan should ignore such variable and program must not fail.
+
+int *ptr;
+
+void f(int cond) {
+ if (cond)
+ goto label;
+ int tmp = 1;
+
+label:
+ ptr = &tmp;
+ *ptr = 5;
+}
+
+int main() {
+ f(1);
+ return 0;
+}
OpenPOWER on IntegriCloud