https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128172

            Bug ID: 128172
           Summary: ICE (segfault) in fixup_noreturn_call during DOM after
                    dead EH edge purge removed the call
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lzy20000419 at outlook dot com
  Target Milestone: ---

void abort(void);
static int cnt;
static void __attribute__((noinline)) die(void) { cnt++; abort(); }
typedef void (*fp_t)(void);
static void cl(fp_t *q) { (*q)(); }
void f(fp_t p) { if (p != die) return; fp_t x __attribute__((cleanup(cl))) = p;
p(); }
fp_t get(void) { return die; }
$ gcc -O1 -fexceptions -c t.c during GIMPLE pass: dom t.c: In function 'f':
t.c:6:6: internal compiler error: Segmentation fault

The same thing happens in C++ with a destructor instead of the cleanup
attribute, at plain g++ -O1:


extern "C" void abort () noexcept;
typedef void (*fp) ();
static int cnt;
static void __attribute__((noinline)) die () { cnt++; abort (); }
struct D { fp p; ~D () { p (); } };
int f0 (fp p)
{
  if (p != die)
    return 0;
  D d { p };
  p ();
  return 0;
}
It fails with every version I tried: 7.5, 9.5, 12.5, 13.4, 14.2, 14.4, 15.3,
16.2 and trunk. So it's not a regression.

https://godbolt.org/z/bcdEfj755 (trunk)

Disclaimer: This test case was generated by a fuzzer, and the report was
written with LLM assistance.

Reply via email to