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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1

--- Comment #15 from Martin Liška <marxin at gcc dot gnu.org> ---
Ok, I've got a reduced test-case:

$ cat bit-cp-crash.c
int
__attribute__((noinline))
foo(int arg)
{
  if (arg == 3)
    return 1;
  if (arg == 4)
    return 123;

  __builtin_unreachable ();
}

int
__attribute__((noinline))
baz(int x)
{
  if (x != 0)
    return foo(3); /* called */

  return 1;
}

int
__attribute__((noinline))
bar(int x)
{
  if (x == 0)
    return foo(5); /* not executed */

  return 1;
}

int main(int argc, char **argv)
{
  int a = bar(argc);
  int b = baz(argc);

  __builtin_printf ("a: %d\n", a);
  __builtin_printf ("b: %d\n", b);
  if (a != b)
    __builtin_abort ();

  return 0;
}

$ gcc bit-cp-crash.c -O2 -flto && ./a.out 
Segmentation fault (core dumped)

It's a recursive call in:
==14411== Process terminating with default action of signal 11 (SIGSEGV):
dumping core
==14411==  Access not within mapped region at address 0x1FFE801FF8
==14411== Stack overflow in thread #1: can't grow stack to 0x1ffe801000
==14411==    at 0x40118F: baz (in /tmp/a.out)
==14411==  If you believe this happened as a result of a stack
==14411==  overflow in your program's main thread (unlikely but
==14411==  possible), you can try to increase the size of the
==14411==  main thread stack using the --main-stacksize= flag.
==14411==  The main thread stack size used in this run was 8388608.
==14411== Stack overflow in thread #1: can't grow stack to 0x1ffe801000

because:

__attribute__((noinline))
foo (int arg)
{
  <bb 2> [count: 0]:
  __builtin_unreachable ();

}

Reply via email to