From Jason Turner
Watch on YouTube

Summary

This episode examines a powerful optimization capability specific to the Clang compiler called heap elision. Jason demonstrates how Clang can completely eliminate heap allocations (new/delete operations) when it can prove they have no observable effects outside their scope, an optimization enabled by a change in the C++14 standard. Through assembly output comparisons between GCC and Clang, he shows cases where Clang produces drastically simpler code by removing memory allocations entirely. The episode also explores interesting side effects of this optimization, including potentially hiding memory leaks in development that might appear on other platforms, and limitations when dealing with more complex constructs like std::vector.

Resources

Tags