https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86141
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |missed-optimization Status|UNCONFIRMED |NEW Last reconfirmed| |2018-06-14 CC| |hubicka at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> --- When you rename main() to foo() the calls are inlined. GCC doesn't inline them into main() because it knows they are executed exactly once which means they are cold and thus code growth doesn't outweight performance increase. With -Winline you see: t.C: In function ‘int main()’: t.C:31:1: warning: inlining failed in call to ‘void DisplayViewType(const ViewType&)’: call is unlikely and code size would grow [-Winline] DisplayViewType( const ViewType& view ) { ^~~~~~~~~~~~~~~ t.C:38:20: note: called from here DisplayViewType( ViewType::view2( data ) ); ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ t.C:31:1: warning: inlining failed in call to ‘void DisplayViewType(const ViewType&)’: call is unlikely and code size would grow [-Winline] DisplayViewType( const ViewType& view ) { ^~~~~~~~~~~~~~~ t.C:37:20: note: called from here DisplayViewType( ViewType::view1( data ) ); ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ of course in the end the size heuristics are off and inlining would reduce code size.