re PR sanitizer/85029 (-fsanitize=undefined internal compiler error: in maybe_optimiz...
authorJakub Jelinek <jakub@gcc.gnu.org>
Fri, 23 Mar 2018 08:55:53 +0000 (09:55 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 23 Mar 2018 08:55:53 +0000 (09:55 +0100)
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

gcc/ChangeLog
gcc/sanopt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ubsan/pr85029.C [new file with mode: 0644]

index c6cdf21789b834fc73eaba75be8be07b6d53729c..9b22865704815d5c8173941dcf011b2682fe56aa 100644 (file)
@@ -1,3 +1,9 @@
+2018-03-23  Jakub Jelinek  <jakub@redhat.com>
+
+       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  <kelvin@gcc.gnu.org>
 
        * config/rs6000/rs6000-builtin.def: Remove various BU_ALTIVEC_X
index 116bc380f826d9dfa1c39df9cb0fa5c013784691..223c06a83557ece5caeb7adb639a68b08d6d4f2a 100644 (file)
@@ -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;
index 560e6d38b840b32c3d5d3e8f8234cabdff2286e2..87c8970d364d5388b0b6ca34ee1c9e4e6b9e5301 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-23  Jakub Jelinek  <jakub@redhat.com>
+
+       PR sanitizer/85029
+       * g++.dg/ubsan/pr85029.C: New test.
+
 2018-03-23  Alexandre Oliva <aoliva@redhat.com>
 
        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  <kargl@gcc.gnu.org
+2018-03-22  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        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 (file)
index 0000000..07472af
--- /dev/null
@@ -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);
+}