作者tinlans ( )
看板C_and_CPP
标题Re: [问题] C++ FQA 文章中,有关 dangling refere …
时间Mon Feb 23 20:11:24 2009
※ 引述《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 (
[email protected])
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