On Sun, 2003-06-29 at 12:51, Matthias Klose wrote: > Please could you check, if the always_inline attribute (gcc-snapshot > package) works for you?
I don't see why that'd help? (btw, it didn't work, tested with gcc version 3.4 20030706 (experimental)) the problem is the following: when compiling the following with -O2 template<typename T> T foo(T); template<typename T> inline T foo(T t) { return t; } // __attribute((always_inline)) long bar (long); inline long bar (long l) { return l; } void doo (long &l) { l = foo (l); l = bar (l); } Disassembly of section .text: 00000000 <doo(long&)>: 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 53 push %ebx 4: 83 ec 10 sub $0x10,%esp 7: 8b 5d 08 mov 0x8(%ebp),%ebx a: ff 33 pushl (%ebx) c: e8 fc ff ff ff call d <doo(long&)+0xd> d: R_386_PC32 long foo<long>(long) 11: 89 03 mov %eax,(%ebx) 13: 83 c4 10 add $0x10,%esp 16: 8b 5d fc mov 0xfffffffc(%ebp),%ebx 19: c9 leave 1a: c3 ret Disassembly of section .gnu.linkonce.t._Z3fooIlET_S0_: 00000000 <long foo<long>(long)>: 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 8b 45 08 mov 0x8(%ebp),%eax 6: c9 leave 7: c3 ret i.e. bar get's inlined, but foo<long> does not... why? btw, gcc-2.95 would optimize it into a NOP: 00000000 <doo(long &)>: 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: c9 leave 4: c3 ret -- I'd say that's a regression... > > Herbert Valerio Riedel writes: > > Package: libstdc++5-3.3-dev > > Version: 1:3.3-2 > > Severity: minor > > > > > > I just noticed, that std::conj() doesn't get inlined, as one'd expect it > > to be; > > > > it seems that a forward declaration like > > > > template<typename _Tp> complex<_Tp> conj(const complex<_Tp>&); > > > > keeps > > > > template<typename _Tp> > > inline complex<_Tp> > > conj(const complex<_Tp>& __z) > > { return complex<_Tp>(__z.real(), -__z.imag()); } > > > > from honoring the 'inline' keyword at all; > > by either removing the forward declaration completely, or adding the > > inline keyword to it like: > > > > template<typename _Tp> inline complex<_Tp> conj(const complex<_Tp>&); > > > > g++ happily inlines the function again... > > > > I don't know whether this is a bug at all (after all inline'ing is > > optional... :-)... > > > > -- System Information: > > Debian Release: testing/unstable > > Architecture: i386 > > Kernel: Linux lfdux.ifs.tuwien.ac.at 2.4.20-1-k7 #1 Sat Mar 22 15:17:52 EST > > 2003 i686 > > Locale: LANG=C, LC_CTYPE=C > > > > Versions of packages libstdc++5-3.3-dev depends on: > > ii g++-3.3 1:3.3-2 The GNU C++ compiler > > ii gcc-3.3-base 1:3.3-2 The GNU Compiler Collection > > (base > > ii libc6-dev 2.3.1-17 GNU C Library: Development > > Librari > > ii libstdc++5 1:3.3-2 The GNU Standard C++ Library v3 > > > > -- no debconf information > > > > > > > > -- > > To UNSUBSCRIBE, email to [EMAIL PROTECTED] > > with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED] -- Herbert Valerio Riedel / Phone: (EUROPE) +43-1-58801-18840 Email: [EMAIL PROTECTED] / Finger [EMAIL PROTECTED] for GnuPG Public Key GnuPG Key Fingerprint: 7BB9 2D6C D485 CE64 4748 5F65 4981 E064 883F 4142