crash when filling a big buffer

D

Daniel Etzold

Why does this crash?

#include <string.h>
int main( int argc, char** argv ) {
char b[ 16000000 ];
memset( b, 0, 16000000 );
}

gcc crash.cc -o crash
 
A

Al Bowers

Daniel said:
Why does this crash?

#include <string.h>
int main( int argc, char** argv ) {
char b[ 16000000 ];
memset( b, 0, 16000000 );
}

gcc crash.cc -o crash

"crash.cc" has the aroma of c++, anyway,
You have exceeded the limits provided by Standard C.

<quote>
5.2.4.1 Translation limits
1 The implementation shall be able to translate and execute at
least one program that contains at least one instance of every
one of the following limits:13)

-- 65535 bytes in an object (in a hosted environment only)

13) Implementations should avoid imposing fixed translation limits
whenever possible.
</quote>

An implementation is not compelled by the Standard to
successfully translate crash.cc.
 
J

jacob navia

Daniel said:
Why does this crash?

#include <string.h>
int main( int argc, char** argv ) {
char b[ 16000000 ];
memset( b, 0, 16000000 );
}

gcc crash.cc -o crash

Because you have exceeded the allowable stack size.
Consult your OS documentation to see how you would change those limits.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top