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

            Bug ID: 101373
           Summary: PRE hoists trapping instructions over possibly
                    throwing calls
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

int __attribute__((const,noipa)) foo (int j)
{
  if (j != 0)
    throw 1;
  return 0;
}

int __attribute__((noipa)) bar (int *p, int n)
{
  int ret = 0;
  if (n)
    {
       foo (n);
       ret = *p;
    }
  ret += *p;
  return ret;
}

int main()
{
  try
    {
      return bar (nullptr, 1);
    }
  catch (...)
    {
      return 0;
    }
}


Here PRE hoists *p before the if (n) which it may not do.

Reply via email to