When can the C++ compiler devirtualize a call?

Someone recently asked me about devirtualization optimizations: when do they happen?
when can we rely on devirtualization? do different compilers do devirtualization
differently? As usual, this led me down an experimental rabbit-hole. The answer
seems to be: Modern compilers devirtualize calls to final methods pretty reliably.
But there are many interesting corner cases — including some I haven’t thought of,
I’m sure! — and different compilers do catch different subsets of those corner cases.
70 points by lionkor 158 days ago quuxplusone.github.io 52 comments
Summary not yet generated for this article.

Comments (52 of ) ⌛

Loading more comments... ⌛
Scroll down to load more comments
No comments available.
Type to search HN and engineering blog articles
Press Escape to close  |  ↑↓ to navigate  |  Enter to open