title: gcc -finline-functions behaviour?
body: <p>I'm using gcc with the -finline-functions optimization for release builds.  In order to combat code bloat because I work on an embedded system I want to say don't inline particular functions.  The obvious way to do this would be through function attributes ie <strong>attribute</strong>(noinline).  The problem is this doesn't seem to work when I switch on the global -finline-functions optimisation which is part of the -O3 switch.  </p>
  
  <p>It also has something to do with it being templated as a non templated version of the same function doesn't get inlined which is as expected. </p>
  
  <p>Has anybody any idea of how to control inlining when this global switch is on?</p>
  
  <p>Here's the code: </p>
  
  <pre><code>#include &lt;cstdlib&gt;
  #include &lt;iostream&gt;
  
  using namespace std;
  
  class Base
  {
  public:
  
      template&lt;typename _Type_&gt;
      static _Type_ fooT( _Type_ x, _Type_ y ) __attribute__ (( noinline ));
  };
  
  template&lt;typename _Type_&gt;
  _Type_ Base::fooT( _Type_ x, _Type_ y )
  {
      asm("");
      return x + y;
  }
  
  
  int main(int argc, char *argv[])
  {
      int test = Base::fooT( 1, 2 );
      printf( "test = %d\n", test );
  
      system("PAUSE");
      return EXIT_SUCCESS;
  }
  </code></pre>