[cfe-dev] GCC and clang discrepancy in operator lookup
Daniel Berenyi via cfe-dev
cfe-dev at lists.llvm.org
Thu Feb 18 00:59:38 PST 2016
Dear All,
Consider the following code:
struct X{};
struct Y{};
struct B
{
void f(X) { }
void operator[](X){}
};
struct C
{
void f(Y) { }
void operator[](Y){}
};
struct D : B, C {};
int main()
{
D d;
d.f(X()); //This is erroneous in all compilers
d[Y()];//this is accepted by clang and MSVC, rejected by GCC
}
What are the rules followed by clang to find the matching operator, that
are different for operators and ordinary functions? Can someone elaborate
on this difference compared to GCC from the standards perspective?
The original question (link
<http://stackoverflow.com/questions/35373384/operator-lookup-into-template-base-classes>)
was in a context where B, C and D are template classes. The same behaviour
applies in that case for all compilers, but figuring out the causes now
involves dependent name look up. Contributions to that discussion are also
welcome.
Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160218/a99cbbe6/attachment.html>
More information about the cfe-dev
mailing list