This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c++/250: Global scoping operator fails in template class
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/250: Global scoping operator fails in template class
- From: matt_conway at i2 dot com
- Date: 26 May 2000 20:58:09 -0000
- Reply-To: matt_conway at i2 dot com
- Resent-Cc: gcc-prs at gcc dot gnu dot org
- Resent-Reply-To: gcc-gnats@gcc.gnu.org, matt_conway@i2.com
>Number: 250
>Category: c++
>Synopsis: Global scoping operator fails in template class
>Confidential: no
>Severity: critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Fri May 26 14:06:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator: matt_conway@i2.com
>Release: egcs 20000501 on i686-pc-linux-gnu
>Organization:
>Environment:
i686-pc-linux-gnu
>Description:
The following code fails to compile - for some reason the compiler tries to use the local method of the same name as the global method, even though we are explicitly using the global scoping (::Bar) operator to call the method. If we make the class/method non-templates, everything compiles fine.
g++ -g -c gcc-scope-bug.cpp
gcc-scope-bug.cpp: In method `void Foo<T>::Bar (T *) [with T =
gcc-scope-bug.cpp: double]':
gcc-scope-bug.cpp:9: instantiated from here
gcc-scope-bug.cpp:10: no matching function for call to
gcc-scope-bug.cpp:10: `Foo<double>::Bar (double *&)'
template <class T> void Bar(T *p)
{
}
template <class T>
class Foo
{
public:
Foo(T *p) { Bar(p); }
void Bar(T *p) { ::Bar<T>(p); }
};
int main()
{
double* d;
Foo<double> f(d);
}
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: