re PR sanitizer/86406 ([UBSAN] -fcompare-debug failure with -fsanitize=undefined)
authorJakub Jelinek <jakub@redhat.com>
Tue, 10 Jul 2018 08:04:14 +0000 (10:04 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 10 Jul 2018 08:04:14 +0000 (10:04 +0200)
PR sanitizer/86406
* cp-gimplify.c (cp_maybe_instrument_return): Skip trailing
DEBUG_BEGIN_STMTs.

* g++.dg/ubsan/pr86406.C: New test.

From-SVN: r262536

gcc/cp/ChangeLog
gcc/cp/cp-gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ubsan/pr86406.C [new file with mode: 0644]

index 86d4a349905975de544b1cfbe52bcb9045c48aa8..5fc7f05d3d05c5b102ef0ad10fb3b2e734b50195 100644 (file)
@@ -1,5 +1,9 @@
 2018-07-10  Jakub Jelinek  <jakub@redhat.com>
 
+       PR sanitizer/86406
+       * cp-gimplify.c (cp_maybe_instrument_return): Skip trailing
+       DEBUG_BEGIN_STMTs.
+
        PR c++/86443
        * semantics.c (handle_omp_for_class_iterator): Remove lastp argument,
        instead of setting *lastp turn orig_declv elt into a TREE_LIST.
index 16831fc710027dc86fb8548e562c27c0b309847b..145af26f18db6b36a4ed3d2d39d49d48816be2f1 100644 (file)
@@ -1621,6 +1621,13 @@ cp_maybe_instrument_return (tree fndecl)
        case STATEMENT_LIST:
          {
            tree_stmt_iterator i = tsi_last (t);
+           while (!tsi_end_p (i))
+             {
+               tree p = tsi_stmt (i);
+               if (TREE_CODE (p) != DEBUG_BEGIN_STMT)
+                 break;
+               tsi_prev (&i);
+             }
            if (!tsi_end_p (i))
              {
                t = tsi_stmt (i);
index e2bc00d18f3e7bd6867dd732f5a5f94c71dbd2d1..da079abfd5b6a2488fbb5abbc76c8f2477ee2b37 100644 (file)
@@ -1,5 +1,8 @@
 2018-07-10  Jakub Jelinek  <jakub@redhat.com>
 
+       PR sanitizer/86406
+       * g++.dg/ubsan/pr86406.C: New test.
+
        PR fortran/86421
        * gfortran.dg/vect/pr86421.f90: New test.
 
diff --git a/gcc/testsuite/g++.dg/ubsan/pr86406.C b/gcc/testsuite/g++.dg/ubsan/pr86406.C
new file mode 100644 (file)
index 0000000..1a0f478
--- /dev/null
@@ -0,0 +1,33 @@
+// PR sanitizer/86406
+// { dg-do compile }
+// { dg-options "-fcompare-debug -fsanitize=undefined -g -O1" }
+
+typedef enum { } cmd_status;
+class ECell;
+class ECell_const_ptr { };
+class ECell_ptr
+{
+  ECell *mp_element;
+  ECell *getPointer () const { return mp_element; }
+public:
+  operator  ECell_const_ptr () const { return ECell_const_ptr(); }
+};
+
+extern ECell_ptr NULL_CELL;
+class VwUI_2DCellLayerView;
+class view_cell_layoutImpl
+{
+  cmd_status handleChangeFlags (VwUI_2DCellLayerView *
+                                      p_ui_celllayerview,
+                                      ECell_const_ptr p_peekCell);
+  cmd_status openCellLayoutView ();
+};
+
+cmd_status
+view_cell_layoutImpl::openCellLayoutView ()
+{
+  ECell_const_ptr pcell = NULL_CELL;
+  VwUI_2DCellLayerView *p_user_interface;
+  return handleChangeFlags (p_user_interface, pcell);
+  ;
+}