This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/20812] contextual overload resolution failure for a member name found in two base classes
- From: "SWElef at post dot sk" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 15 Apr 2005 07:30:44 -0000
- Subject: [Bug c++/20812] contextual overload resolution failure for a member name found in two base classes
- References: <20050407180310.20812.SWElef@post.sk>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From SWElef at post dot sk 2005-04-15 07:30 -------
I was wrong. std:10.2/2 (member name lookup) says
[snip] If the resulting set of declarations are not all from sub-objects of
the same type, or the set has a nonstatic member and includes members from
distinct sub-objects, there is an ambiguity and the program is ill-formed.
[snip]
So the deduction may not succeed. On the other hand, IIRC it is also not
supposed to fail since the paragraph 14.8.2/2 that names all reasons for
deduction failure does not contain anything about this specific case. The
only reason that seems a little similar reads
Attempting to use a type in the qualifier portion of a qualified name that
names a type when that type does not contain the specified member, or if the
specified member is not a type where a type is required.
and in this case the named type _contains_ the specified member, it's just
ambiguous.
To expose the problem I wrote this new snippet:
struct B1{ typedef int T; };
struct B2{ typedef int T; };
struct D : B1, B2 { };
template <typename X>
typename X::T foo() { return X::T(); }
int main(){ foo<D>(); }
gcc reports "error: no matching function for call to `foo()'". Comeau Online
says "error: "D::T" is ambiguous" which is very different (and IIRC correct).
May be this PR should be resolved as INVALID and another one should be written
with this snippet and a more appropriate subject.
Regards,
Vladimir Marko
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20812