Recently, I've been trying to find out the difference between copy-initialization (e.g. in return
statements) and direct-initialization (e.g. in static_cast
expressions). Besides the explicit
keyword, the code posted by Johannes really caught my attention because recent versions of GCC and Clang exhibit different behaviors for the mentioned code. Upon further investigation, it may be surprising that these behaviors are somewhat intentional. In the following, I will try to explain this corner case of initialization in C++. This post may be a bit arcane. Anyway, have fun reading!
Given the following code:
// -std=c++23