------- Comment #1 from lo at meep dot co dot uk  2008-01-09 11:42 -------
In addition, the following code fails with:

try.h: In function ‘int main()’:
try.h:9: sorry, unimplemented: inlining failed in call to ‘const T&
X::min(const T&, const T&) [with T = int]’: function not inlinable
y.cpp:5: sorry, unimplemented: called from here

Again, supplementing the first declaration of min with "inline __attribute__
((always_inline))" allows the code to compile successfully.

======================

# 1 "y.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "y.cpp"
# 1 "try.h" 1


namespace X
{
 template <class T>
 const T& min(const T& a, const T& b);

 template <class T>
 inline __attribute__ ((always_inline)) const T& min(const T& a, const T& b)
 {
  return a < b ? a : b;
 }
}
# 2 "y.cpp" 2
template <class T>
inline __attribute__ ((always_inline)) T y(const T& a, const T& b)
{
 return X::min(a, b);
}
int main()
{
 int a, b;
 return y(a, b);
}


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34715

Reply via email to