public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/16963] New: Ambiguity? Seems implausible
@ 2004-08-10 14:09 igodard at pacbell dot net
2004-08-10 14:22 ` [Bug c++/16963] " igodard at pacbell dot net
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: igodard at pacbell dot net @ 2004-08-10 14:09 UTC (permalink / raw)
To: gcc-bugs
struct C{};
struct D{};
template<typename T>
struct Foo {
void Bar(T t) {}
};
struct R : public Foo<C>, public Foo<D> {};
int main() {
C c;
D d;
R r;
r.Bar(c);
r.Bar(d);
return 0;
}
gets you:
~/ootbc/members/src$ c++ foo.cc
foo.cc: In function `int main()':
foo.cc:14: error: request for member `Bar' is ambiguous
foo.cc:5: error: candidates are: void Foo<T>::Bar(T) [with T = D]
foo.cc:5: error: void Foo<T>::Bar(T) [with T = C]
foo.cc:15: error: request for member `Bar' is ambiguous
foo.cc:5: error: candidates are: void Foo<T>::Bar(T) [with T = D]
foo.cc:5: error: void Foo<T>::Bar(T) [with T = C]
--
Summary: Ambiguity? Seems implausible
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: igodard at pacbell dot net
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16963
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/16963] Ambiguity? Seems implausible
2004-08-10 14:09 [Bug c++/16963] New: Ambiguity? Seems implausible igodard at pacbell dot net
@ 2004-08-10 14:22 ` igodard at pacbell dot net
2004-08-10 14:24 ` bangerth at dealii dot org
2004-08-10 18:15 ` reichelt at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: igodard at pacbell dot net @ 2004-08-10 14:22 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From igodard at pacbell dot net 2004-08-10 14:22 -------
Simpler testcase (no templates):
struct C{};
struct D{};
struct X {
void Bar(C t) {}
};
struct Y {
void Bar(D t) {}
};
struct R : public X, public Y {};
int main() {
C c;
D d;
R r;
r.Bar(c);
r.Bar(d);
return 0;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16963
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/16963] Ambiguity? Seems implausible
2004-08-10 14:09 [Bug c++/16963] New: Ambiguity? Seems implausible igodard at pacbell dot net
2004-08-10 14:22 ` [Bug c++/16963] " igodard at pacbell dot net
@ 2004-08-10 14:24 ` bangerth at dealii dot org
2004-08-10 18:15 ` reichelt at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: bangerth at dealii dot org @ 2004-08-10 14:24 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-08-10 14:23 -------
icc rejects the code with the same error, though I must admit that I am
at present at a loss as to why.
A slightly simplified example is this:
---------------------
template <typename T>
struct Foo {
int Bar(T);
};
struct R : public Foo<int>, public Foo<char> {};
int i = R().Bar(1);
---------------------
g/x> /home/bangerth/bin/gcc-3.5-pre/bin/c++ -c x.cc
x.cc:8: error: request for member `Bar' is ambiguous
x.cc:3: error: candidates are: int Foo<T>::Bar(T) [with T = char]
x.cc:3: error: int Foo<T>::Bar(T) [with T = int]
It is true that name lookup happens before argument conversion, but
I can't at present explain why not both functions are found at the
same time and then overload resolution happens.
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16963
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/16963] Ambiguity? Seems implausible
2004-08-10 14:09 [Bug c++/16963] New: Ambiguity? Seems implausible igodard at pacbell dot net
2004-08-10 14:22 ` [Bug c++/16963] " igodard at pacbell dot net
2004-08-10 14:24 ` bangerth at dealii dot org
@ 2004-08-10 18:15 ` reichelt at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2004-08-10 18:15 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From reichelt at gcc dot gnu dot org 2004-08-10 18:15 -------
GCC and icc are right.
[10.2]/2 states:
The following steps define the result of name lookup in class scope.
First, every declaration for the name in the class and in each of its
base class sub-objects is considered. [...] If the resulting set of
declarations are not all from sub-objects of the same type [...]
there is an ambiguity and the program is ill-formed. [...]
Overload resolution takes place later, see [10.2]/4.
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |reichelt at gcc dot gnu dot
| |org
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16963
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-08-10 18:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-10 14:09 [Bug c++/16963] New: Ambiguity? Seems implausible igodard at pacbell dot net
2004-08-10 14:22 ` [Bug c++/16963] " igodard at pacbell dot net
2004-08-10 14:24 ` bangerth at dealii dot org
2004-08-10 18:15 ` reichelt at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).