This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: bad inlining
- To: egcs-bugs at cygnus dot com
- Subject: Re: bad inlining
- From: Steven Parkes <parkes at sierravista dot com>
- Date: Wed, 15 Jul 1998 17:00:04 -0700
- Organization: Sierra Vista Research, Inc.
Appended is a very short, runable file that demonstrates the inlining
problem we are having. As this one is a complete show stopper for us,
I'll look at it (as much as I can.) If anyone more familar with templates
and inlining sees something obvious ...
BAD: ./cc1plus bad.C && gcc bad.s && ./a.out
result:
0x080472e0
0x080472e0
GOOD: ./cc1plus bad.C && gcc bad.s && ./a.out
result:
0x00000000
0x080472e0
class Linked
{
public:
Linked();
class Element;
Element* headOf() const { return head; }
void clear();
Element* head;
};
class Chained : public Linked
{
public:
Element* headOf() const;
};
inline Chained::Element*
Chained::headOf() const
{
(Element*) Linked::headOf();
}
template <class T> class ChainElement;
template <class T>
class Chain : public Chained
{
public:
Chain() {}
typedef ChainElement<T> Element;
void clear();
Element* headOf() const;
};
template <class T>
inline
ChainElement<T>*
Chain<T>::headOf() const
{
return (ChainElement<T>*) Chained::headOf();
}
extern "C" int printf( char const*, ... );
template <class T>
void
Chain<T>::clear()
{
Element* ptr = headOf();
printf( "0x%08x\n", ptr );
printf( "0x%08x\n", this );
Chained::clear();
}
template class Chain<int> ;
int
main()
{
Chain<int> x;
x.clear();
}
void Linked::clear() {}
Linked::Linked():head(0) {}