This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
g++ bug?
- From: "Thomas, Steve" <steve dot thomas at mbda dot co dot uk>
- To: "'gcc at gcc dot gnu dot org'" <gcc at gcc dot gnu dot org>
- Cc: "Boothman, John" <john dot boothman at mbda dot co dot uk>, "Miller, Martin" <martin dot miller at mbda dot co dot uk>, "Simpson, John" <john dot simpson at mbda dot co dot uk>
- Date: Mon, 04 Oct 2004 10:29:28 +0100
- Subject: g++ bug?
Hi,
I think I have found a bug in g++, to do with scoping rules, but I'm not
sufficiently expert on the language to be sure. Here is a simple test case:
#include <stdio.h>
class ZZZ {
public:
ZZZ ()
{
printf ("ZZZ constructor\n");
}
int aaa;
};
template<typename T>
class BBB {
public:
void ZZZ (void)
{
printf ("BBB.ZZZ\n");
}
};
template<typename T>
class AAA : public BBB<T> {
public:
void YYY (void)
{
ZZZ();
}
};
int main (void)
{
AAA<int> a;
a.YYY();
return 0;
}
When built & run with g++ V3.3.1, it generates the output "ZZZ constructor".
In other words, the call to ZZZ() in AAA.YYY() has called the constructor of
class ZZZ in preference to function ZZZ in the base class. This doesn't seem
right to me. This behaviour only seems to occur if classes AAA & BBB are
templates, but I haven't experimented too widely to be sure of this.
Any comments anyone?
Thanks,
Steve Thomas
MBDA (UK)
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************