Well, there is no guarantee by the standard that inline functions are actually inlined; one must use macros to have 100 % guarantee. The compiler always decides which function is or is not inlined based on its own rules irrespective of the inline keyword.
Then when will the inline keyword actually have some effect to what the compiler does when using modern compilers such as the recent version of GCC?
It has a semantic effect. To simplify, a function marked
inlinemay be defined multiple times in one program — though all definitions must be equivalent to each other — so presence ofinlineis required for correctness when including the function definition in headers (which is, in turn, makes the definition visible so the compiler can inline it without LTO).Other than that, for inlining-the-optimization, "never" is a perfectly safe approximation. It probably has some effect in some compilers, but nothing worth losing sleep over, especially not without actual hard data. For example, in the following code, using Clang 3.0 or GCC 4.7,
maincontains the same code whetherworkis markedinlineor not. The only difference is whetherworkremains as stand-alone function for other translation units to link to, or is removed.