A Usable C++ Dialect That Is Safe Against Memory Corruption
This works, although the downside compared to Rust is that soft pointer validity is checked at runtime, meaning that a program that compiles can still randomly fail at runtime and that performance is worse due to the checks.<p>The key idea and massive difference from standard C++ is that object destruction is delayed until a &quot;quiescient state&quot; happens in what is a reframing of RCU [<a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Read-copy-update" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Read-copy-update</a>], allowing to freely use raw pointers as long as none survive across a quiescient state.<p>[note however that this system allows to take pointers to stack variables, so they have to restrict raw pointers to function arguments only - it would be better to also introduce a &quot;heap-only&quot; pointer that can be freely returned&#x2F;stored on the heap&#x2F;etc. but can&#x27;t be stored in types that live across a quiescient state, from which stack-or-heap raw pointers can be derived]<p>This also results in the downside that things like mutexes can only be safe if they are kept locked until a quiescient state happens, since that&#x27;s the only lifetime that the system understands.<p>Likewise, you can&#x27;t do this like prevent updating a collection while iterating unless you are fine with freezing the collection until a quiescient state happens.<p>In general, you are much better off using Rust (or an equivalently expressive language, if it existed), since that allows to statically check for correctness, not have to delay freeing memory, and allows to use lifetimes and linear types to secure mutex locking, collection iteration, and other things where lifetimes are essential.