<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/110009>110009</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[C++] Lookup for function call syntax to implicitly declared copy-assignement fails in template classes
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
TheCalligrapher
</td>
</tr>
</table>
<pre>
For the following code
```
template <typename = int> struct C
{
C &foo(const C &c) { return operator =(c); }
};
int main()
{
C<> c;
c.foo(c);
}
```
Clang will generate a diagnostic
```
error: explicit qualification required to use member 'operator=' from dependent base class
3 | C &foo(const C &c) { return operator =(c); }
|
```
The code appears to be perfectly valid, yet it is rejected by Clang. The above diagnostic mentions "base class", although obviously there's no inheritance of any kind in this code.
Prepending the call to copy-assigment with `this->`
` C &foo(const C &c) { return this->operator =(c); }`
solves the problem (which incidentally is how one solves the "lookup in a dependent base class" issues).
Also, switching from functional notation to operator-in-expression notation makes the error to go away
` C &foo(const C &c) { return *this = c; }`
Trying to qualify the call
` C &foo(const C &c) { return C::operator =(c); }`
results in
```
error: no member named 'operator=' in 'C<type-parameter-0-0>'
3 | C &foo(const C &c) { return C::operator =(c); }
|
```
With non-template classes the issue does not manifest itself.
The diagnostic implies that when functional notation is used to refer to the implicitly declared copy-assignment operator in a template class (from within a member definition), name lookup fails for some unknown reason, and the compiler immediately jumps to conclusion that it is a "lookup in a dependent base class" issue. It is obviously not.
Anyway, is this a known issue? Or am I missing some peculiarity of name lookup in template classes?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVlFvozoT_TXOyygRMUloHvLQ0o200id992Gl-2zMEGZrbNY2zfLvr8aQNK2i7t7VRQhIsMczZ845RoVAJ4t4ENsnsX1eqCG2zh--tVgqY-jkVd-iX1SuHg9H5yG2CI0zxp3JnkC7GkFkzyJ7nK-7bD7Tz4hdb1REEHkZxx6t6vj5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