Stack Exchange
segmentation fault with big array size
The following piece of code compiles and runs without any problems:
#include <stdbool.h>
#define N 1000000

int main( void ){

  bool num[N];
  bool *p;
  for( p = num; p < &num[N]; )
    *p++ = true;
}

If, however, the value of N gets 10 times bigger (extra 0 -- ten million instead of one million),
#include <stdbool.h>
#define N 10000000

int main( void ){

  bool num[N];
  bool *p;
  for( p = num; p < &num[N]; )
    *p++ = true;
}

I get a segmentation fault on the line beginning with for. What is going on here? I don't see anything special about going from 1000000 to 10000000 (million to ten million).

Which OS ? And what's your stack size limitation ? (ulimit -a under linux)

@dasblinkenlight Thanks, I now see that the problem is that the stack size has been exceeded.

@Pierre Thanks -- I see that the problem is with the stack size limit. Thanks for your help!

@dmitry Yes - that's it! Stack errors are notoriously hard to catch in C, especially when the allocation is done statically.
