[LLVMbugs] [Bug 11543] New: ambiguous qualified class member access lookup diagnostic unclear
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Dec 12 02:19:13 PST 2011
http://llvm.org/bugs/show_bug.cgi?id=11543
Bug #: 11543
Summary: ambiguous qualified class member access lookup
diagnostic unclear
Product: clang
Version: unspecified
Platform: PC
OS/Version: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: richard-llvm at metafoo.co.uk
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
This question came up on stackoverflow:
http://stackoverflow.com/questions/8100492/ambiguous-member-access-expression-is-clang-rejecting-valid-code
Testcase, for posterity:
template<typename T>
class TemplateClass : public T {
public:
void method() {}
template<typename U>
static void static_method(U u) { u.TemplateClass::method(); }
};
class EmptyClass {};
int main() {
TemplateClass<TemplateClass<EmptyClass> > c;
TemplateClass<EmptyClass>::static_method(c);
}
Clearly our diagnostic for this code is insufficient, since it's taken a month
and a +500 rep bounty for someone to figure out why the code is ill-formed. We
say:
example.cc:6:38: error: lookup of 'TemplateClass' in member access expression
is
ambiguous
static void static_method(U u) { u.TemplateClass::method(); }
^
example.cc:13:3: note: in instantiation of function template specialization
'TemplateClass<EmptyClass>::static_method<TemplateClass<TemplateClass<EmptyClass>
> >' requested here
TemplateClass<EmptyClass>::static_method(c);
^
example.cc:2:7: note: lookup in the object type
'TemplateClass<TemplateClass<EmptyClass> >' refers here
class TemplateClass : public T {
^
example.cc:2:7: note: lookup from the current scope refers here
These last two notes are clearly trying to indicate the problem, but since they
don't list the template arguments they fail to point out the problem. The
problem would be more obvious if we said:
example.cc:2:7: note: lookup in the object type
'TemplateClass<TemplateClass<EmptyClass> >' refers here [with T =
TemplateClass<EmptyClass>]
class TemplateClass : public T {
^
example.cc:2:7: note: lookup from the current scope refers here [with T =
EmptyClass]
It could also be useful to mention that the lookup found an injected-class-name
(but that wouldn't help in this particular case).
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list