Segmentation Fault doesn't come up immediately after accessing out-of-bound memory

后端 未结 5 999
旧时难觅i
旧时难觅i 2020-12-20 11:51

I wrote this piece of code and was expecting a segmentation fault quicly, but it seems I am allowed to access pieces of memory I shouldn\'t be able to.

#inc         


        
5条回答
  •  孤城傲影
    2020-12-20 12:15

    Accessing beyond the end of an array is undefined behaviour. Anything may happen. It may work, it may fail, it may reformat your hard drive or it might post questions on stack overflow.

    Sometimes it seg faults

提交回复
热议问题