This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/34715] always_inline does not seem to force inlining when used only in the definition of a function in a namespace



------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]