c++/5660: g++ 2.95.x and 3.0.x fails to properly handle dependant names involving templates & inheritance
auroran@dominia.mit.edu
auroran@dominia.mit.edu
Mon Feb 11 14:16:00 GMT 2002
>Number: 5660
>Category: c++
>Synopsis: g++ 2.95.x and 3.0.x fails to properly handle dependant names involving templates & inheritance
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Feb 11 12:46:02 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: auroran@dominia.mit.edu
>Release: 3.0.3
>Organization:
>Environment:
x86 Linux/FreeBSD
>Description:
I found this in the "Bug++" section of a late 2001 edition of Windows Developer magazine which fails to produce the correct results compiled with g++ (and msvc, bcb, ...). A small program demonstrates the bug. The relevant section of the standard appears to be 14.6.2.
>How-To-Repeat:
// Demonstrates name lookup bug in most popular C++ compilers.
// This program should print "In ::f()" if it is compliant
// to the C++ standard.
#include <iostream>
using namespace std;
template<typename T>
void f( T& aT )
{
cout << "In ::f()\n";
}
struct base {
virtual void f( base& )
{
cout << "In base::f()\n";
}
};
template<typename T> struct W : public T
{
void g( W& w )
{
f(w);
}
};
int main()
{
W<base> wb;
wb.g(wb);
return 0;
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list