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

前端 未结 10 1752
心在旅途
心在旅途 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:01

    There are some extension in gcc for that (from compiler side) http://www.doc.ic.ac.uk/~awl03/projects/miro/

    on the other hand splint, rat and quite a few other static code analysis tools would have found that.

    You also can use valgrind on your code and see the output. http://valgrind.org/

    another widely used library seems to be libefence

    It's simply a design decision ones made. Which now leads to this things.

    Regards Friedrich

提交回复
热议问题