In this article, we’ll explore how C++’s abstraction model heavily relies on compiler optimizations, unveiling some unfortunate examples of unexpected performance loss. Afterwards, we will compare how the three major compilers (GCC, Clang, and MSVC) fare in this area, and we’ll discuss some potential future improvements or workarounds.
the sad state of debug performance in c++
by Vittorio Romeo
From the article:
C++ developers should know that `std::move(0)` is semantically the same as `static_cast<int&&>(0)`, and most of them would expect the compiler to generate no code for the move, even with optimizations disabled. Turns out that GCC 12.2, Clang 14.0, and MSVC v19.x all end up generating a call instruction. [...]
Add a Comment