The following program causes Segmentation fault being compiled with
gcc (GCC) 4.0.1 (Debian 4.0.1-2)

#include <stdio.h>
int main() {
    char A[ 1UL << 24 ];
    A[0] = 0;
    puts("OK");
    return 0;
}

$ gcc test.c
$ ./a.out
Segmentation fault

If array of the same size (16M) is dinamically allocated (e.g., via malloc())
everything works as expected.

debian-amd64 with 4G physical memory here.

-- 
           Summary: Segmentation fault when large static array is declared
           Product: gcc
           Version: 4.0.1
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: relf at os2 dot ru
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23054

Reply via email to