久久久久久久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(開始調(diào)試)從 Visual C++ 2008 運行此代碼,這總是會導致崩潰(訪問沖突.)但是,在 IDE 之外啟動此可執(zhí)行文件,或使用 IDE 的Ctrl+F5(不調(diào)試啟動)不會導致任何崩潰.可能有什么不同?

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?

我也想知道是否可以穩(wěn)定重現(xiàn)訪問已刪除區(qū)域?qū)е碌脑L問沖突崩潰?這種崩潰在現(xiàn)實生活中很少見嗎?

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?

推薦答案

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

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

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

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.

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

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

相關(guān)文檔推薦

Difference between std::reference_wrapper and simple pointer?(std::reference_wrapper 和簡單指針的區(qū)別?)
Difference between const. pointer and reference?(常量之間的區(qū)別.指針和引用?)
How to access the contents of a vector from a pointer to the vector in C++?(c++ - 如何從指向向量的指針訪問向量的內(nèi)容?)
Meaning of *amp; and **amp; in C++(*amp; 的含義和**amp;在 C++ 中)
Why can#39;t I do polymorphism with normal variables?(為什么我不能對普通變量進行多態(tài)?)
Is pointer comparison undefined or unspecified behavior in C++?(C++ 中的指針比較是未定義或未指定的行為嗎?)
主站蜘蛛池模板: 天堂一区二区三区 | www.午夜 | 国产一级特黄 | 欧美日韩亚洲另类 | 亚洲精品视频在线 | 国产黄色免费观看 | 美女免费网站 | 亚洲小视频 | 国产在线视频91 | 亚洲色综合 | 国产成人久久精品麻豆二区 | 久久在线精品 | 免费a视频| 国产日韩久久 | 欧美综合激情 | 国产在线小视频 | 日韩成人影视 | 成人av免费看 | 欧美久久一区 | 在线看亚洲 | 午夜视频在线免费观看 | 久久综合久久鬼 | 黄色三级在线观看 | 日韩网站免费观看 | 手机av在线 | 亚洲三区四区 | 久久黄色大片 | 日本黄a三级三级三级 | 国产黄色在线播放 | 夜夜欢视频 | 三级网站免费 | 欧美成人毛片 | 成人黄性视频 | 色妞网站 | 秘密爱大尺度做爰呻吟 | 久久一区二区视频 | 天天色播 | 国产精品成人一区二区网站软件 | 日韩一区二区免费视频 | 亚洲69视频 | 欧美性受xxxx黑人xyx性爽 |