https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110845
Xi Ruoyao <xry111 at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |xry111 at gcc dot gnu.org Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #3 from Xi Ruoyao <xry111 at gcc dot gnu.org> --- (In reply to KL from comment #2) > Changed main to foo: > same behavior It's because you don't have a return statement in foo, causing an undefined behavior. And GCC considers undefined behaviors highly improbable to be executed, so the same logic (not to inline too much into "cold" code paths) still applies. If you add the return statement they are inlined: https://godbolt.org/z/Ko9r4fn3d