This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/34715] always_inline with templates and not declared as always_inline but definition has it
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 31 Jan 2008 19:51:50 -0000
- Subject: [Bug c++/34715] always_inline with templates and not declared as always_inline but definition has it
- References: <bug-34715-15505@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from pinskia at gcc dot gnu dot org 2008-01-31 19:51 -------
Hi, namespace has nothing to do with the issue,
The problem can be summarized as follows:
if you have a declaration of the template function without always_inline and
the definition with, the instationation does not get always_inline.
Take this testcase:
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;
}
int main()
{
int a, b;
return min(a, b);
}
We don't inline min into main if we remove the declaration, we do.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Component|tree-optimization |c++
Ever Confirmed|0 |1
Keywords| |wrong-code
Last reconfirmed|0000-00-00 00:00:00 |2008-01-31 19:51:49
date| |
Summary|always_inline does not seem |always_inline with templates
|to force inlining when used |and not declared as
|only in the definition of a |always_inline but definition
|function in a namespace |has it
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34715