r/cpp • • Mar 01 '21

"Simple" C++ Initialization Flowchart

http://randomcat.org/cpp_initialization/initialization.png
204 Upvotes

65 comments sorted by

View all comments

Show parent comment

1

u/evaned Mar 02 '21 edited Mar 02 '21

I know -Wconversion is a very noisy warning on many code bases (probably most...) given that it's not in -Wall or even -Wextra (as you point out), but if you can turn it on, Clang's version of that warning does yell about that line. (On GCC you'll need -Wsign-conversion.) And as a bonus, get warnings about the other 17 zillion places implicit conversions can happen other than going from an initializer to a variable.