看板 C_and_CPP 關於我們 聯絡資訊
※ 引述《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