Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

11
  • 10
    You might be getting confused with string overruns. Commented Jan 20, 2016 at 12:56
  • 20
    Homework: Modify a simple CPU so that it does spill. You'll see that the logic gets far more complex, all for a "feature" that would guarantee security holes everywhere without being useful in the first place. Commented Jan 20, 2016 at 15:05
  • 4
    If you need really huge numbers, it is possible to have a number representation that increases how much memory it uses to fit large numbers. The processor itself can't do this, and it's not a feature of the C language, but a library can implement it - a common C library is the GNU Multiple Precision arithmetic library. The library has to manage memory to store the numbers which has a performance cost on top of the arithmetic. A lot of languages have this kind of thing built in (which doesn't avoid the costs). Commented Jan 20, 2016 at 15:10
  • 1
    write a simple test, I'm not a C programmer but something along the lines of int c = INT.MAXINT; c+=1; and see what happened to c. Commented Jan 20, 2016 at 20:41
  • 2
    @JonH: The problem is that overflow in Undefined Behavior. A C compiler may spot that code, and deduce that it's unreachable code because it unconditionally overflows. Since unreachable code doesn't matter, it can be eliminated. End result: no code left. Commented Jan 21, 2016 at 7:57