2019-08-30 Jakub Jelinek Backported from mainline 2019-02-08 Jakub Jelinek PR rtl-optimization/89234 * except.c (copy_reg_eh_region_note_forward): Return if note_or_insn is a NOTE, CODE_LABEL etc. - rtx_insn * other than INSN_P. (copy_reg_eh_region_note_backward): Likewise. * g++.dg/ubsan/pr89234.C: New test. --- gcc/except.c (revision 268715) +++ gcc/except.c (revision 268716) @@ -1755,6 +1755,8 @@ copy_reg_eh_region_note_forward (rtx not if (note == NULL) return; } + else if (is_a (note_or_insn)) + return; note = XEXP (note, 0); for (insn = first; insn != last ; insn = NEXT_INSN (insn)) @@ -1777,6 +1779,8 @@ copy_reg_eh_region_note_backward (rtx no if (note == NULL) return; } + else if (is_a (note_or_insn)) + return; note = XEXP (note, 0); for (insn = last; insn != first; insn = PREV_INSN (insn)) --- gcc/testsuite/g++.dg/ubsan/pr89234.C (nonexistent) +++ gcc/testsuite/g++.dg/ubsan/pr89234.C (revision 268716) @@ -0,0 +1,11 @@ +// PR rtl-optimization/89234 +// { dg-do compile { target dfp } } +// { dg-options "-O2 -fnon-call-exceptions -fsanitize=null" } + +typedef float __attribute__((mode (SD))) _Decimal32; + +void +foo (_Decimal32 *b, _Decimal32 c) +{ + *b = c + 1.5; +}