https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126702
Xi Ruoyao <xry111 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |xry111 at gcc dot gnu.org
--- Comment #7 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
> Therefore there is no choice; the compiler must use the only definition
> provided. Thus, the code above is valid C; it does not contain unspecified
> behavior, much less undefined behavior.
???
Annex J clearly states it's unspecified "whether a call to an inline function
uses the inline definition or the external definition
of the function (6.7.4)."
And the choice is valid for optimization: if the compiler is compiling a cold
code path it's a perfectly sensible choice to optimize it for size instead of
speed, so calling the function would be better than inlining a copy. Here main
can be considered a cold path because in C main can only execute once (calling
main is undefined behavior).