From: Jakub Jelinek Date: Tue, 27 Jun 2017 07:23:54 +0000 (+0200) Subject: re PR sanitizer/81209 (-fsanitize=undefined ICE on darwin) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c103185290d8e69b03ab40678093514821615abd;p=gcc.git re PR sanitizer/81209 (-fsanitize=undefined ICE on darwin) PR sanitizer/81209 * ubsan.c (ubsan_encode_value): Initialize DECL_CONTEXT on var. * g++.dg/ubsan/pr81209.C: New test. From-SVN: r249678 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e9dc0d6f2ba..128e8f7d726 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,8 @@ 2017-06-27 Jakub Jelinek + PR sanitizer/81209 + * ubsan.c (ubsan_encode_value): Initialize DECL_CONTEXT on var. + PR middle-end/81207 * gimple-fold.c (replace_call_with_call_and_fold): Handle gimple_vuse copying separately from gimple_vdef copying. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0217b7f0bee..fecfd6211ae 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2017-06-27 Jakub Jelinek + PR sanitizer/81209 + * g++.dg/ubsan/pr81209.C: New test. + PR middle-end/81207 * gcc.c-torture/compile/pr81207.c: New test. diff --git a/gcc/testsuite/g++.dg/ubsan/pr81209.C b/gcc/testsuite/g++.dg/ubsan/pr81209.C new file mode 100644 index 00000000000..3f2a5768907 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/pr81209.C @@ -0,0 +1,21 @@ +// PR sanitizer/81209 +// { dg-do compile } +// { dg-options "-fsanitize=undefined -fno-declone-ctor-dtor" } + +#ifdef __SIZEOF_INT128__ +typedef __int128 T; +#else +typedef long long int T; +#endif + +struct B {}; +struct A : virtual public B +{ + A (long); + T a; +}; + +A::A (long c) +{ + long b = a % c; +} diff --git a/gcc/ubsan.c b/gcc/ubsan.c index 44effdd2216..c7a06ef0e8d 100644 --- a/gcc/ubsan.c +++ b/gcc/ubsan.c @@ -153,6 +153,7 @@ ubsan_encode_value (tree t, enum ubsan_encode_value_phase phase) { var = create_tmp_var_raw (type); TREE_ADDRESSABLE (var) = 1; + DECL_CONTEXT (var) = current_function_decl; } if (phase == UBSAN_ENCODE_VALUE_RTL) {