Do not instrument static target_expr for use-after-scope (PR sanitizer/90570).
authorMartin Liska <mliska@suse.cz>
Thu, 23 May 2019 10:12:01 +0000 (12:12 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Thu, 23 May 2019 10:12:01 +0000 (10:12 +0000)
2019-05-23  Martin Liska  <mliska@suse.cz>

PR sanitizer/90570
* gimplify.c (gimplify_target_expr): Skip TREE_STATIC target
expression similarly to gimplify_decl_expr.
2019-05-23  Martin Liska  <mliska@suse.cz>

PR sanitizer/90570
* g++.dg/asan/pr90570.C: New test.

From-SVN: r271548

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/asan/pr90570.C [new file with mode: 0644]

index 45294c250473c08ab57bff4959344d861423cb2d..2ccb803d5c6857a9757e5c69391e3671e2435c50 100644 (file)
@@ -1,3 +1,9 @@
+2019-05-23  Martin Liska  <mliska@suse.cz>
+
+       PR sanitizer/90570
+       * gimplify.c (gimplify_target_expr): Skip TREE_STATIC target
+       expression similarly to gimplify_decl_expr.
+
 2019-05-23  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>
 
        * cse.c (cse_dump_path): s/dump_file/f.
index 6905165ad330302f051de192c99975222d8549ad..8337b36c4115d3523f8cae66b572ee020de506c5 100644 (file)
@@ -6668,6 +6668,7 @@ gimplify_target_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
            }
          if (asan_poisoned_variables
              && DECL_ALIGN (temp) <= MAX_SUPPORTED_STACK_ALIGNMENT
+             && !TREE_STATIC (temp)
              && dbg_cnt (asan_use_after_scope)
              && !gimplify_omp_ctxp)
            {
index e422d71bdfe1abb79d2249bda56f57c06aad281a..b34d1cc74b4a27dfb840e786e1ee71f750802e7c 100644 (file)
@@ -1,3 +1,8 @@
+2019-05-23  Martin Liska  <mliska@suse.cz>
+
+       PR sanitizer/90570
+       * g++.dg/asan/pr90570.C: New test.
+
 2019-05-23  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/opt78.ad[sb]: New test.
diff --git a/gcc/testsuite/g++.dg/asan/pr90570.C b/gcc/testsuite/g++.dg/asan/pr90570.C
new file mode 100644 (file)
index 0000000..c236690
--- /dev/null
@@ -0,0 +1,18 @@
+/* PR sanitizer/90570 */
+/* { dg-do run } */
+
+#include <vector>
+
+struct stru
+{
+  std::vector<int> v{1,2,3,4};
+  int i{5};
+};
+
+int main()
+{
+  stru s1;
+  stru s2;
+
+  return 0;
+}