This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
C++ generates bad assembly code
- To: egcs-bugs at cygnus dot com
- Subject: C++ generates bad assembly code
- From: David Mazieres <dm at reeducation-labor dot lcs dot mit dot edu>
- Date: Tue, 16 Jun 1998 20:39:47 -0400 (EDT)
With recent versions of egcs:
gcc version egcs-2.91.40 19980610 (gcc2 ss-980502 experimental)
gcc version egcs-2.91.41 19980616 (gcc2 ss-980502 experimental)
The following program compiles to incorrect assembly code if you do
not optimize. (It works with gcc2 and egcs 1.03.)
On an OpenBSD i386 machine, I get the following:
% c++ -c egcs-bug.C
/var/tmp/ccCSF766.s: Assembler messages:
/var/tmp/ccCSF766.s:28: Fatal error:Symbol ___t11ihash_entry1Z7element already defined.
% c++ -c egcs-bug.C |& c++filt
/var/tmp/ccER3108.s: Assembler messages:
/var/tmp/ccER3108.s:28: Fatal error:Symbol ihash_entry<element>::ihash_entry(void) already defined.
Thanks,
David
===
template<class T>
class ihash_entry {
};
template<class T, ihash_entry<T> T::*field>
struct ihash_core {
ihash_core () {}
};
template<class T, ihash_entry<T> T::*field>
struct ihash : public ihash_core<T, field>
{
ihash () {}
};
struct element {
ihash_entry<element> hlink;
};
ihash<element, &element::hlink> etab;