This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: template functions not inlined
- From: Joe Buck <Joe dot Buck at synopsys dot COM>
- To: Dan Nicolaescu <dann at ics dot uci dot edu>
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 2 Feb 2004 09:57:38 -0800
- Subject: Re: template functions not inlined
- References: <200402010443.i114hhSn010319@gremlin.ics.uci.edu>
On Sat, Jan 31, 2004 at 08:43:44PM -0800, Dan Nicolaescu wrote:
>
> The following trivial example shows that template functions defined at
> the top level are not inlined by any version of gcc.
>
> template<typename T> int func (T t) { return 25; }
> void bar(void) { func (17); }
>
> Intel's compiler inlines func into bar.
GCC will inline the function if it is written
template<typename T> inline int func (T t) { return 25; }