This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/250: Global scoping operator fails in template class



>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:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]