This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/34715] always_inline does not seem to force inlining when used only in the definition of a function in a namespace
- From: "lo at meep dot co dot uk" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Jan 2008 11:42:15 -0000
- Subject: [Bug tree-optimization/34715] always_inline does not seem to force inlining when used only in the definition of a function in a namespace
- References: <bug-34715-15505@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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