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

            Bug ID: 120028
           Summary: SIGSEGV at runtime from large static array
                    initialization accepted silently by GCC
           Product: gcc
           Version: 13.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mario.rodriguezb1 at um dot es
  Target Milestone: ---

I am not sure it this is exactly a bug, but i have seen that it only occurs in
gcc, not in clang, and exactly in some versions of gcc only, from 4.7.3 to
13.3. If compiled with -O3 it is stopped by an SIGSEV, if not a gcc: internal
compiler error arises. Locally i get: collect2: fatal error: ld terminated with
signal 9 [Killed]

```
#include <stdlib.h>
int main() {
        static const struct {
                int (*func)(void);
        } ptrs[0xFFFFFFFF] = { { malloc } };
        ptrs[200].func();
return 0;}
```

To quickly reproduce:

Without -O3
https://gcc.godbolt.org/z/vP3Y4noEj

With -O3 
https://gcc.godbolt.org/z/fzjnxvvGv
  • [Bug c/120028] New: SIGSEGV at... mario.rodriguezb1 at um dot es via Gcc-bugs

Reply via email to