From: Jakub Jelinek Date: Fri, 23 Mar 2018 08:55:53 +0000 (+0100) Subject: re PR sanitizer/85029 (-fsanitize=undefined internal compiler error: in maybe_optimiz... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ee3a999fe7dfddb2531b045738ff2c0c40e6eb4c;p=gcc.git re PR sanitizer/85029 (-fsanitize=undefined internal compiler error: in maybe_optimize_ubsan_ptr_ifn, at sanopt.c:493) PR sanitizer/85029 * sanopt.c (maybe_optimize_ubsan_ptr_ifn): If DECL_REGISTER (base), just don't try to optimize it rather than assert it never happens. * g++.dg/ubsan/pr85029.C: New test. From-SVN: r258794 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c6cdf21789b..9b228657048 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-03-23 Jakub Jelinek + + PR sanitizer/85029 + * sanopt.c (maybe_optimize_ubsan_ptr_ifn): If DECL_REGISTER (base), + just don't try to optimize it rather than assert it never happens. + 2018-03-22 Kelvin Nilsen * config/rs6000/rs6000-builtin.def: Remove various BU_ALTIVEC_X diff --git a/gcc/sanopt.c b/gcc/sanopt.c index 116bc380f82..223c06a8355 100644 --- a/gcc/sanopt.c +++ b/gcc/sanopt.c @@ -488,9 +488,9 @@ maybe_optimize_ubsan_ptr_ifn (sanopt_ctx *ctx, gimple *stmt) &unsignedp, &reversep, &volatilep); if ((offset == NULL_TREE || TREE_CODE (offset) == INTEGER_CST) && DECL_P (base) + && !DECL_REGISTER (base) && pbitpos.is_constant (&bitpos)) { - gcc_assert (!DECL_REGISTER (base)); offset_int expr_offset; if (offset) expr_offset = wi::to_offset (offset) + bitpos / BITS_PER_UNIT; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 560e6d38b84..87c8970d364 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-03-23 Jakub Jelinek + + PR sanitizer/85029 + * g++.dg/ubsan/pr85029.C: New test. + 2018-03-23 Alexandre Oliva PR c++/71251 @@ -15,7 +20,7 @@ * g++.old-deja/g++.robertl/eb58.C: Likewise. * g++.old-deja/g++.robertl/eb63.C: Likewise. -2018-03-22 Steven G. Kargl PR fortran/84922 * gfortran.dg/interface_42.f90: New test. diff --git a/gcc/testsuite/g++.dg/ubsan/pr85029.C b/gcc/testsuite/g++.dg/ubsan/pr85029.C new file mode 100644 index 00000000000..07472af16a5 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/pr85029.C @@ -0,0 +1,15 @@ +// PR sanitizer/85029 +// { dg-do compile } +// { dg-skip-if "" { *-*-* } { "-flto -fno-fat-lto-objects" } } +// { dg-options "-fsanitize=undefined" } + +struct B { + virtual B bar (); + int e; +} register a; // { dg-error "register name not specified for 'a'" } + +int +foo (...) +{ + return foo (a); +}