https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89937

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Walt Karas from comment #2)
> Hmmm it seems you are saying that inline (or weak linkage by any other name)
> in C++ somehow prohibits inlining.

I think in this instance, the inlining heuristics have decided not to inline
it, because it's an extern function. Possibly to prevent increasing the binary
size too much, but that's just a guess.

If it has internal linkage then the compiler knows there are no other callers,
just the one in this translation unit, so inlining it reduces code size and
avoids the function call overhead, win-win.

> I thought that, in C++, a weak linkage
> function may or may not be inlined.  If it isn't, its object code must be in
> a vague linkage section.

Right.

> But there is no requirement for its object code to
> appear in a vague linkage section, is there?

Right. Any other translation unit that uses the inline function must also be
able to see the definition, and so another vague linkage definition will be
generated in any object that needs it.

Reply via email to