help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Performance penalty on inline empty function


From: Paul Pluzhnikov
Subject: Re: Performance penalty on inline empty function
Date: Sat, 16 Apr 2005 08:06:25 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux)

"pmatos" <pocm@sat.inesc-id.pt> writes:

> Will an inlined empty function have any performance penalty,

Yes under some conditions, no under other conditions.

Gcc will not inline any function at all if you compile without
optimization. Even with -O2, some versions of gcc will not inline
functions that are used before their body is available, e.g.

  struct Foo {
      int foo() { return bar(); }
      int bar() { return 42; }
  };
  int func() { Foo f; return f.foo(); }

The call to foo() is inlined (with -O3) by both g++-2.95 and
g++-3.4.3, but call to bar() is only inlined by g++-3.4.3.

> i.e., will g++ generate any code at all for it?

This question is not the same as the first one.

If you take address of an inline function, g++ will be forced to
define the symbol and produce code for it. But this is orthogonal
to whether calling this function has any performance penalty
(i.e. whether the function *call* is inlined or not).

Cheers,
-- 
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]