久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

取消引用已刪除的指針總是會導致訪問沖突?

Dereferencing deleted pointers always result in an Access Violation?(取消引用已刪除的指針總是會導致訪問沖突?)
本文介紹了取消引用已刪除的指針總是會導致訪問沖突?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我這里有一個非常簡單的 C++ 代碼:

I have a very simple C++ code here:

char *s = new char[100];
strcpy(s, "HELLO");
delete [] s;
int n = strlen(s);

如果我通過按 F5(開始調試)從 Visual C++ 2008 運行此代碼,這總是會導致崩潰(訪問沖突.)但是,在 IDE 之外啟動此可執行文件,或使用 IDE 的Ctrl+F5(不調試啟動)不會導致任何崩潰.可能有什么不同?

If I run this code from Visual C++ 2008 by pressing F5 (Start Debugging,) this always result in crash (Access Violation.) However, starting this executable outside the IDE, or using the IDE's Ctrl+F5 (Start without Debugging) doesn't result in any crash. What could be the difference?

我也想知道是否可以穩定重現訪問已刪除區域導致的訪問沖突崩潰?這種崩潰在現實生活中很少見嗎?

I also want to know if it's possible to stably reproduce the Access Violation crash caused from accessing deleted area? Is this kind of crash rare in real-life?

推薦答案

通過刪除的指針訪問內存是未定義行為.您不能期望任何可靠/可重復的行為.

Accessing memory through a deleted pointer is undefined behavior. You can't expect any reliable/repeatable behavior.

很可能在一種情況下它有效",因為字符串仍然坐在那里"在現在可用的內存中 -= 但你不能依賴它.VS 使用調試值填充內存以幫助強制崩潰以幫助查找這些錯誤.

Most likely it "works" in the one case because the string is still "sitting there" in the now available memory -= but you cannot rely on that. VS fills memory with debug values to help force crashes to help find these errors.

這篇關于取消引用已刪除的指針總是會導致訪問沖突?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Difference between std::reference_wrapper and simple pointer?(std::reference_wrapper 和簡單指針的區別?)
Difference between const. pointer and reference?(常量之間的區別.指針和引用?)
How to access the contents of a vector from a pointer to the vector in C++?(c++ - 如何從指向向量的指針訪問向量的內容?)
Meaning of *amp; and **amp; in C++(*amp; 的含義和**amp;在 C++ 中)
Why can#39;t I do polymorphism with normal variables?(為什么我不能對普通變量進行多態?)
Is pointer comparison undefined or unspecified behavior in C++?(C++ 中的指針比較是未定義或未指定的行為嗎?)
主站蜘蛛池模板: h在线| 欧美一区二区三区在线 | 天天操操| 国产成人精品综合 | 一区二区影院 | 紧缚调教一区二区三区视频 | 亚洲高清网 | 中文字幕在线观看视频一区 | 亚洲成人一二区 | 一级片在线观看 | 国产成人短视频在线观看 | 欧美日韩中文字幕在线播放 | 亚洲人成人网 | 久久国产欧美日韩精品 | 在线资源视频 | 久久丝袜视频 | 国产精品99久久久久久动医院 | 日日天天 | 日韩电影中文字幕 | 久久久国产一区二区 | h视频免费在线观看 | 国产成人精品一区二区三 | 在线看91| 久久亚洲国产精品日日av夜夜 | 欧美a区 | 国产福利精品一区 | 手机av在线 | 欧美精品tv | 激情网站 | 91国产视频在线 | 国产亚洲精品久久久久久豆腐 | 欧美美女被c | 久久中文一区二区 | 国产激情一区二区三区 | 涩在线| 欧美激情一区二区 | 国产三级精品视频 | 精品国产乱码久久久久久图片 | 免费视频一区二区 | 精品国产免费人成在线观看 | 国产在线观看免费 |