When do compilers inline functions?

c++, compiler-construction, inline, inlining, optimization

Solution

Yes, the compiler can inline code even if it's not explicitly declared as `inline`.

Basically, as long as the semantics are not changed, the compiler can virtually do anything it wants to the generated code. The standard does not force anything special on the generated code.

Problem

In C++, do functions only get inlined if they are explicitly declared `inline` (or defined in a header file), or are compilers allowed to inline functions as they see fit?

Original source