Getting Segmentation Fault

后端 未结 5 1949
我寻月下人不归
我寻月下人不归 2020-11-27 19:21

I saw many questions about getting segmentation fault in C program here in SO, and I thought it would be great to have a reference to those here, a question

5条回答
  •  独厮守ぢ
    2020-11-27 19:54

    1. Undefined Behaviour: trying to change a string literal
    2. Undefined Behaviour: writing past the end of the array
    3. Undefined Bahaviour: passing to free() a pointer not obtained through malloc()
    4. Undefined Behaviour: passing to free() an invalid pointer
    5. Undefined Behaviour: incompatabilities between the printf() format specifier and actual argument types
    6. Undefined Behaviour: passing to free() an invalid pointer

    Undefined Behaviour can manifest itself by a "segmentation fault", but that is by no means a required outcome. Anything could have happened :)

提交回复
热议问题