When can the C++ compiler devirtualize a call?
Summary
This article investigates when C++ devirtualization occurs in practice, focusing on two main scenarios: known dynamic type and proof-of-leafness (final or internal linkage). It compares how major compilers (GCC, Clang, MSVC, ICC) handle various corner cases, discusses the role of LTO, and presents a table of results, offering insights into what developers can rely on for performance.