On 09/19/24 7:59 PM, Andrey Tarasevich wrote:
struct A {};
template <typename = int> struct C
{
C() = default;
C(const A &) {}
C &operator =(const A &a) { return operator =(C(a)); }
};
int main()
{
A a;
C<> c;
c = a;
}
This significantly reduced version of the code sheds some light on the
inner workings of the bug
template <typename = int> struct C
{
C &foo(const C &c) { return operator =(c); }
};
int main()
{
C<> c;
c.foo(c);
}
Clang complains with
error: explicit qualification required to use member 'operator=' from dependent base class
3 | C &foo(const C &c) { return operator =(c); }
"Dependent base class"? What "dependent base class"? There are no base
classes involved in this example.
Apparently Clang decides that a reference to an implicitly-declared copy-assignment operator is an accidental reference to an operator from
a base class (since it does not see an explicit declaration here). This
also explains why `this->` provides a workaround.
--
Best regards,
Andrey
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)