[Bug c/126702] undefined reference to inline function

"xry111 at gcc dot gnu.org via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
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).
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.