g++ 4.1.2 compiler error
<p>I have the following code (stripped down version from actual project to reproduce 
the issue) that results in a compiler error on RHEL5 (g++ version 4.1.2):</p>

<pre><code>----------- driver (test.cpp)--------------

#include &lt;iostream&gt;
#include &lt;classa.hpp&gt;
#include &lt;func.hpp&gt;

namespace globals {
  static int kth(const A&amp; a) { 
     return kth(a.ival());
  }
}

using namespace globals;

int main() {
   A a;
   std::cout &lt;&lt; func(a) &lt;&lt; std::endl;
   return 0;
}

----------class A (classa.hpp)------------

class A {
public:
  A():val(0){}
  const int ival() const {return val;}
private:
  int val;
};


------- namespace globals (func.hpp) ------

namespace globals {
   int kth(const int&amp; c) {
      return c;
   }

   template &lt;class T&gt;
   int func(const T&amp; key) {
      return kth(key);
   }
}

--------------------------------------------
</code></pre>

<p>Compiling it using g++ 4.1.2 gives me the following error:</p>

<pre><code>func.hpp: In function ‘int globals::func(const T&amp;) [with T = A]’:
test.cpp:15:   instantiated from here
func.hpp:8: error: invalid initialization of reference of type ‘const int&amp;’ from  
                   expression of type ‘const A’
func.hpp:2: error: in passing argument 1 of ‘int globals::kth(const int&amp;)’
</code></pre>

<p>Same code compiles and runs perfectly fine on RHEL4 (g++ version 3.4.6)! Any explanations/ideas/suggestions on how to resolve this error(?) on RHEL5 will 
be much appreciated!</p>

<p>Edit:
  Thanks Sergey. That is the obvious solution that I am aware of already. But I forgot to add that the restriction is that func.hpp cannot be edited (for e.g., its 3rd party write-protected). Any workarounds?</p>
