Segfault when deleting pointer

后端 未结 5 1492
南笙
南笙 2021-01-03 12:32

I\'ve been experiencing segfaults when running some C++ code. I\'ve isolated the problem to a line in the program that deletes a pointer. Here\'s a simple example that pro

5条回答
  •  礼貌的吻别
    2021-01-03 13:25

    When you delete a pointer that wasn't allocated with new, you're creating a conflict between the memory management system and the stack. Each will operate as if it still has sole ownership of the memory, and a crash can result when they overwrite each other's values.

提交回复
热议问题