diff options
author | Jakub Jelinek <jakub@redhat.com> | 2018-11-28 09:49:08 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2018-11-28 09:49:08 +0100 |
commit | ace83db06c03b138c8b4cf87bf3db61f2d842e60 (patch) | |
tree | e4a15dbcfd4276091ffc6f69327bebcb0dc72031 | |
parent | fc60283c5c7987a120cdadd24024a0319bfe0360 (diff) | |
download | gcc-ace83db06c03b138c8b4cf87bf3db61f2d842e60.zip gcc-ace83db06c03b138c8b4cf87bf3db61f2d842e60.tar.gz gcc-ace83db06c03b138c8b4cf87bf3db61f2d842e60.tar.bz2 |
re PR sanitizer/88215 (UBSAN: Internal compiler error with attribute(unused))
PR c++/88215
* c-ubsan.c: Include langhooks.h.
(ubsan_instrument_division): Change gcc_assert that main variants
of op0 and op1 types are equal to gcc_checking_assert that the
main variants are compatible types.
* c-c++-common/ubsan/pr88215.c: New test.
From-SVN: r266546
-rw-r--r-- | gcc/c-family/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/c-family/c-ubsan.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/ubsan/pr88215.c | 11 |
4 files changed, 28 insertions, 2 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index d993967..bc85a93 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,11 @@ +2018-11-28 Jakub Jelinek <jakub@redhat.com> + + PR c++/88215 + * c-ubsan.c: Include langhooks.h. + (ubsan_instrument_division): Change gcc_assert that main variants + of op0 and op1 types are equal to gcc_checking_assert that the + main variants are compatible types. + 2018-11-27 Eric Botcazou <ebotcazou@adacore.com> * c-ada-spec.c: Include stringpool.h. diff --git a/gcc/c-family/c-ubsan.c b/gcc/c-family/c-ubsan.c index 4ef2bd8..7b8a7eb 100644 --- a/gcc/c-family/c-ubsan.c +++ b/gcc/c-family/c-ubsan.c @@ -31,6 +31,7 @@ along with GCC; see the file COPYING3. If not see #include "stringpool.h" #include "attribs.h" #include "asan.h" +#include "langhooks.h" /* Instrument division by zero and INT_MIN / -1. If not instrumenting, return NULL_TREE. */ @@ -44,8 +45,9 @@ ubsan_instrument_division (location_t loc, tree op0, tree op1) /* At this point both operands should have the same type, because they are already converted to RESULT_TYPE. Use TYPE_MAIN_VARIANT since typedefs can confuse us. */ - gcc_assert (TYPE_MAIN_VARIANT (TREE_TYPE (op0)) - == TYPE_MAIN_VARIANT (TREE_TYPE (op1))); + tree top0 = TYPE_MAIN_VARIANT (type); + tree top1 = TYPE_MAIN_VARIANT (TREE_TYPE (op1)); + gcc_checking_assert (lang_hooks.types_compatible_p (top0, top1)); op0 = unshare_expr (op0); op1 = unshare_expr (op1); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 920885b..411a3c8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-11-28 Jakub Jelinek <jakub@redhat.com> + + PR c++/88215 + * c-c++-common/ubsan/pr88215.c: New test. + 2018-10-19 Richard Biener <rguenther@suse.de> PR tree-optimization/88182 diff --git a/gcc/testsuite/c-c++-common/ubsan/pr88215.c b/gcc/testsuite/c-c++-common/ubsan/pr88215.c new file mode 100644 index 0000000..5db1664 --- /dev/null +++ b/gcc/testsuite/c-c++-common/ubsan/pr88215.c @@ -0,0 +1,11 @@ +/* PR c++/88215 */ +/* { dg-do compile } */ +/* { dg-options "-fsanitize=integer-divide-by-zero" } */ + +int +foo (void) +{ + int a = 2, __attribute__ ((__unused__)) b = 1; + int f = a / b; + return f; +} |