Re: [問題] C++ FQA 文章中,有關 dangling refere …
※ 引述《zlw (洞房不敗)》之銘言:
: ------------------------------------------------------------------------------
: For example, a wide class of bugs comes from accessing
: dangling references - references to objects which were already destroyed.
: If a reference is the object, or just another name for it, how can that happen?
: ------------------------------------------------------------------------------
: 我知道 dangling pointer 的意思以及怎樣才會發生。
: 但上面說的這個 dangling reference 導致的 bug 要怎樣才能重現我無法理解。
int main()
{
int *ptr = new int;
int &ref = *ptr;
delete ptr;
ref = 10;
...
}
--
Ling-hua Tseng (uranus@tinlans.org)
Department of Computer Science, National Tsing-Hua University
Interesting: C++, Compiler, PL/PD, OS, VM, Large-scale software design
Researching: Software pipelining for VLIW architectures
Homepage: https://www.tinlans.org
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.160.104.77
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 3 篇):
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章