Inline function linkage change?

When a compiler compiles an inline function, it may choose to inline it or not, depending on a number of heuristics, and on current optimization level. The inline is only a suggestion, which the compiler is free to ignore at will If the compiler decides not to inline the function, then it will emit an actual function definition (just as if the function was not declared inline), with weak linkage (so that multiple such definitions do not cause a problem) That is what's happening, and why your program links Your program may stop linking if you crank up optimization level, or use a compiler with different inlining heuristics.

When a compiler compiles an inline function, it may choose to inline it or not, depending on a number of heuristics, and on current optimization level. The inline is only a suggestion, which the compiler is free to ignore at will. If the compiler decides not to inline the function, then it will emit an actual function definition (just as if the function was not declared inline), with weak linkage (so that multiple such definitions do not cause a problem).

That is what's happening, and why your program links. Your program may stop linking if you crank up optimization level, or use a compiler with different inlining heuristics.

A weak symbol was added when there is a call func of the inline func, see: 00000000 **W** _Z2f1ii – user not found Nov 16 at 5:17 add when I add -O1 to g++, it stop linking.. – user not found Nov 16 at 5:29.

In C++ if a function is defined as inline somewhere, it has be to so everywhere from C++ 7.1.2 An inline function shall be defined in every translation unit in which it is used and shall have exactly the same definition in every case (3.2) 3.2 refers to the One Definition Rule So what you are experiencing is non C++ standard behavior.

– user not found Nov 16 at 3:26 In 9.2 of c++98... it states that combination of external linkage and inlining is banned to make life simpler for compiler writers – parapura rajkumar Nov 16 at 3:40.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions