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

            Bug ID: 128151
           Summary: SIGILL at -O0 -fgnu-tm after cancelling a transaction
                    that modifies a local struct
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kyuwoncho18 at gmail dot com
  Target Milestone: ---
            Target: x86_64-pc-linux-gnu

int main(void)
{
  struct { int a; } s = { 1 };
  __transaction_atomic {
    s.a = 2;
    __transaction_cancel;
  }
  return s.a != 1;
}

godbolt: https://godbolt.org/z/eefsdYYjv

The transaction is unconditionally cancelled, so the assignment to s.a must be
rolled back and main must return 0. On x86-64, -O0 -fgnu-tm terminates with
SIGILL (exit status 132), whereas -O1, -O2, -O3 and -Os with -fgnu-tm exit
normally with status 0.

Reply via email to