Why do compilers not warn about out-of-bounds static array indices?

前端 未结 10 1754
心在旅途
心在旅途 2020-12-03 03:07

A colleague of mine recently got bitten badly by writing out of bounds to a static array on the stack (he added an element to it without increasing the array size). Shouldn

10条回答
  •  攒了一身酷
    2020-12-03 04:02

    The C philosophy is that the programmer is always right. So it will silently allow you to access whatever memory address you give there, assuming that you always know what you are doing and will not bother you with a warning.

提交回复
热议问题