crash when filling a big buffer

Discussion in 'C Programming' started by Daniel Etzold, Apr 17, 2005.

  1. 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
    Daniel Etzold, Apr 17, 2005
    #1
    1. Advertising

  2. Daniel Etzold

    Al Bowers Guest

    Daniel Etzold wrote:
    > 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.

    --
    Al Bowers
    Tampa, Fl USA
    mailto: (remove the x to send email)
    http://www.geocities.com/abowers822/
    Al Bowers, Apr 17, 2005
    #2
    1. Advertising

  3. Daniel Etzold

    jacob navia Guest

    Daniel Etzold wrote:

    > 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.
    jacob navia, Apr 17, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shaguf
    Replies:
    0
    Views:
    351
    Shaguf
    Dec 24, 2008
  2. Shaguf
    Replies:
    0
    Views:
    450
    Shaguf
    Dec 26, 2008
  3. Shaguf
    Replies:
    0
    Views:
    238
    Shaguf
    Dec 26, 2008
  4. Shaguf
    Replies:
    0
    Views:
    216
    Shaguf
    Dec 24, 2008
  5. Mohsen Pahlevanzadeh
    Replies:
    0
    Views:
    116
    Mohsen Pahlevanzadeh
    Sep 9, 2013
Loading...

Share This Page