Hello. Due to a stupid mistake I did, following patch is needed for the test-case to properly save previous gimplify_ctxp->live_switch_vars.
Patch can bootstrap on ppc64le-redhat-linux and survives regression tests. I was able to run asan bootstrap on x86_64-linux-gnu and kernel build with allyesconfig works fine. Ready to be installed? Martin
>From 53dd3c035283863a25a24feb90bf359295999bca Mon Sep 17 00:00:00 2001 From: marxin <mli...@suse.cz> Date: Fri, 11 Nov 2016 11:21:29 +0100 Subject: [PATCH] Fix PR sanitizer/78270 (part 2) gcc/ChangeLog: 2016-11-11 Martin Liska <mli...@suse.cz> PR sanitizer/78270 * gimplify.c (gimplify_switch_expr): Always save previous gimplify_ctxp->live_switch_vars. gcc/testsuite/ChangeLog: 2016-11-11 Martin Liska <mli...@suse.cz> PR sanitizer/78270 * gcc.dg/asan/pr78270-2.c: New test. --- gcc/gimplify.c | 8 ++++---- gcc/testsuite/gcc.dg/asan/pr78270-2.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/asan/pr78270-2.c diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 16573dd..c23888b 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -2255,11 +2255,11 @@ gimplify_switch_expr (tree *expr_p, gimple_seq *pre_p) gimplify_ctxp->case_labels.create (8); /* Do not create live_switch_vars if SWITCH_BODY is not a BIND_EXPR. */ + saved_live_switch_vars = gimplify_ctxp->live_switch_vars; if (TREE_CODE (SWITCH_BODY (switch_expr)) == BIND_EXPR) - { - saved_live_switch_vars = gimplify_ctxp->live_switch_vars; - gimplify_ctxp->live_switch_vars = new hash_set<tree> (4); - } + gimplify_ctxp->live_switch_vars = new hash_set<tree> (4); + else + gimplify_ctxp->live_switch_vars = NULL; bool old_in_switch_expr = gimplify_ctxp->in_switch_expr; gimplify_ctxp->in_switch_expr = true; diff --git a/gcc/testsuite/gcc.dg/asan/pr78270-2.c b/gcc/testsuite/gcc.dg/asan/pr78270-2.c new file mode 100644 index 0000000..d1f5d26 --- /dev/null +++ b/gcc/testsuite/gcc.dg/asan/pr78270-2.c @@ -0,0 +1,17 @@ +// { dg-do compile } +// { dg-additional-options "-Wno-switch-unreachable" } + +int a; +void +fn1 () +{ + switch (a) + { + char b; + case 8: + &b; + switch (0) + ; + } +} + -- 2.10.1