Petr Mladek wrote:
Hi,
I am sorry for the late reply. I am quite busy last few days.
On Thursday 10 November 2005 16:37, Joerg Barfurth wrote:
Hi Stephan,
Stephan Bergmann schrieb:
If I understand things correctly, the above problem boils down to
struct A {};
struct B {};
void f(A*);
template<typename T> void g(T t) { f(t); } // line 4
void f(B*);
void h(B*b) { g(b); } // line 6
being rejected by GCC 4.1, on the grounds that f(B*) is not visible at
the point of definition of template g.
No. The problem is slightly different. The above code is OK.
The following more closely matches the problem:
I cleaned up the Joerg's code and added one more struct to print exactly the
same error message as in the OOo code:
namespace NS
{
struct A {};
struct B {};
struct C {};
}
void f(NS::A *); // line 8
namespace NS { void ff(A *); }
void f(NS::B *); // line 11
namespace NS { void ff(B *); }
template<typename T> void g(T t)
{
f(t); // unqualified lookup - this fails //line 16
ff(t); // argument-dependent lookup - this successds
// ::f(t); // qualified id - ??
}
void f(NS::C *);
namespace NS { void ff(C *); }
void h(NS::C*c) { g(c); } //line 25
I get the following message witch gcc-4.1:
$# g++ --version
g++ (GCC) 4.1.0 20051024 (experimental) (SUSE Linux)
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$# g++ -O2 -c /test2.cxx
/test2.cxx: In function ‘void g(T) [with T = NS::C*]’:
/test2.cxx:25: instantiated from here
/test2.cxx:16: error: no matching function for call to ‘f(NS::C*&)’
/test2.cxx:8: note: candidates are: void f(NS::A*)
/test2.cxx:11: note: void f(NS::B*)
$#
It can be compiled with gcc-4.0:
$# g++ --version
g++ (GCC) 4.0.2 20050901 (prerelease) (SUSE Linux)
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$# g++ -c test2.cxx
$#
BTW: If I uncomment the line the ::f(t); (line 18). It cannot be compiled even
with gcc-4.0:
hope:/abuild/OpenOffice.org-2.1.137 # g++ -c test2.cxx
test2.cxx: In function ‘void g(T) [with T = NS::C*]’:
test2.cxx:25: instantiated from here
test2.cxx:18: error: no matching function for call to ‘f(NS::C*&)’
test2.cxx:8: note: candidates are: void f(NS::A*)
test2.cxx:11: note: void f(NS::B*)
I am going to consult it with our gcc expects to get their opinion.
After sending my last mail, it also dawned on me that I had not taken
into account the namespace problem.
A solution that should work is to replace uses of
getCppuType(static_cast< T * >(0));
with uses of
getCppuType<T>();
That function call is handled at template instantiation time in a way
that its correct specialization is found, for any kind of T defined in
whatever namespace. The only problem is that getCppuType<T>() has a
slightly different semantic than getCppuType(T const *), see the comment
in com/sun/star/uno/Type.h. Filed
<http://www.openoffice.org/issues/show_bug.cgi?id=57855>.
-Stephan
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]