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

            Bug ID: 125462
           Summary: [16 Regression] Segfault running SPEC OMP 2012 since
                    -mcmodel=large changes
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ktkachov at gcc dot gnu.org
                CC: wdijkstr at arm dot com
  Target Milestone: ---
            Target: aarch64

Since commit g:b4aa063fe4a4142544a0aad362ef45b2f23165ee I'm seeing runtime
errors when running SPEC OMP 2012 in our regular benchmarking. I've tried to
extract a standalone testcase that fails with the commit and passes before
that.

Compile and run with -O2 -mcmodel=large -fno-PIC repro.c

#include <stdio.h>

static int res;
static int big_arr[10000];

__attribute__((noinline))
static void init_arr (void)
{
  for (int i = 0; i < 10000; i++)
    big_arr[i] = i;
}

__attribute__((noinline))
static int sum_arr (void)
{
  int s = 0;
  for (int i = 0; i < 10000; i++)
    s += big_arr[i];
  return s;
}

__attribute__((noinline))
static void set_res (int v)
{
  res = v;
}

int
main (void)
{
  init_arr ();
  set_res (42);
  int s = sum_arr ();
  int expected = (10000 * 9999) / 2;    /* 49995000 */
  if (res != 42 || s != expected)
    {
      printf ("FAIL: res=%d (expected 42), sum=%d (expected %d)\n",
              res, s, expected);
      return 1;
    }
  printf ("OK\n");
  return 0;
}

Reply via email to