My C arrays are too large

Jose Isaias Cabrera jicman@outlook.com
Wed Sep 18 20:40:00 GMT 2019


Joel Rees, on Wednesday, September 18, 2019 02:38 PM, wrote...
>
> 2019年9月14日(土) 3:50 Jose Isaias Cabrera, on
>
> >
> > Achim Gratz, on Friday, September 13, 2019 02:39 PM, wrote...
> > >
> > > Blair, Charles E III writes:
> > > > My apologies for failing to reply on-list.  I don't know how :(
> > > >
> > > > My machine is 64 bit, and I hope I installed the correct version of
> > cygwin.
> > > >
> > > > This program:
> > > >
> > > > #include<stdio.h>
> > > > int main(){char *a[50][8192];
> > > > return 0;}
> > > >
> > > > compiles with gcc  (no special options) but gives "Segmentation fault".
> > >
> > > You are creating an automatic variable that's larger than the default
> > > stack.  You need to enlarge the stack, either during link time or later
> > > e.g. via
> > >
> > > peflags -x0x800000 a.out
> >
> > This is great! Thanks.
> >
> > But, let's talk about this a bit... Shouldn't the compiler provide some
> > warning, and also, it should never blow up with a "Segmentation fault".  I
> > believe there should be some type of Out Of Memory error, or something like
> > it.  But now just blow up.  Anyone thinks like me?  Just my 102 Dominican
> > cents ($1 = $51 Dominican). :-)
> >
>
> Well, the behavior of the compiler itself is better discussed on the
> compiler's forums, although you may need your asbestos suit when you do so.
>
> That said, why do you want this variable to be automatic? Why do you want
> it allocated on the stack?

I did not say automatically.  I said that the compiler should provide some warning about the allocation being larger than the default stack.  And, it should not result in a segmentation fault, but instead, the program should error out with out of memory, or, at least, "memory allocation is larger than default stack."  Not just blow up.


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list