News Score: Score the News, Sort the News, Rewrite the Headlines

A safe pointer in C++ that protects against use after free and updates when the pointee is moved

Sometimes some object A needs to interact with another object B, e.g., A calls one of B’s methods. In a memory-unsafe language like C++, it is left to the programmer to assure that B outlives A; if B happens to be already destructed, this would be a use-after-free bug. Managing object lifetimes can be tricky, especially with asynchronous code. Perhaps unneeded, but here is a simple example of the problem: struct Foo { void foo(); }; struct Bar { Foo* f; void call_foo() { f->foo(); } }; int main(...

Read more at techblog.rosemanlabs.com

© News Score  score the news, sort the news, rewrite the headlines