Marco Correia wrote:
hi,

The following is a simplification of my problem:

struct Base { virtual void func() = 0; };

struct Derived : Base { inline void func() {...} };

Derived& d = ...;
d.func();

This last call is not being inlined. Is this normal?
Yes. The compiler cannot know that d doesn't reference an object whose type is a class derived from Derived, which overrides func() again. Virtual calls can only be inlined if the compiler can statically determine the dynamic type of the expression.
(As I said my example is more complex, I didn't check if the above is inlined or not). Also in my example, compiling with -Winline does not warn me that it is not inlined. I discovered it only by profiling the executable.
This might be considered a bug.

Sebastian

Reply via email to