Thread: What the...

  1. #16
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    Originally posted by Zach L.
    As everyone has said, its undefined. If that snippet of code is all your program is, then chances are, the program will never actually use that block of memory, so you can (read: should not) do whatever to it without a crash. As your program grows in complexity, however, the chances that you'll actually overwrite and corrupt something that is vital to the program's execution increase significantly. If you do corrupt a part of the stack, then most likely, your program will crash.
    Basically what we are all saying is that it's not going to make the program crash at first, but if you develope a decent program, higher the risk it'll crash...and you'll spend countless hours trying to figure out why, and all that because you didn't use your memory correctly.

  2. #17
    Registered User
    Join Date
    Mar 2002
    Posts
    249
    Ok, thank you all for your replies. I have on more question, though: Is it undefined?

    JUST KIDDING!
    Well, there are a few things wrong with your code:

    1) It does not work.
    2) It does not work.
    3) It does not work.

    Hope this helps.

  3. #18
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    Originally posted by funkydude9
    Ok, thank you all for your replies. I have on more question, though: Is it undefined?

    JUST KIDDING!
    HA! I hope you are......after all this and you still don't know? (hah, just playin w/ ya fd9)

    << EDIT >>: ha, fd9 sounds like an android name [or a cyborg or whatever]

  4. #19
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >I have on more question, though: Is it undefined?
    No, not really. We've just been messing with you.
    My best code is written with the delete key.

  5. #20
    Registered User
    Join Date
    Jun 2003
    Posts
    245
    Put your code in a subroutine, and get subroutine called by another subroutine and that called by another, called by the main program, and THEN try your program. You'll find it crashes everytime. This is because when you call a function, the return address is pushed onto the stack. When you overwrite that address with your out of bounds array indexing, it'll corrupt the return address and so when the function returns, it'll jump into inaccessible memory and crash, every time.

Popular pages Recent additions subscribe to a feed