Open HexadigmSystems opened 3 weeks ago
@llvm/issue-subscribers-clang-frontend
Author: Hexadigm Systems (HexadigmSystems)
This happens in non-SFINAE contexts too:
https://godbolt.org/z/sKvqq1qYx:
struct Base {
private:
int f();
int f(int); // Does not compile if this is removed
};
struct Derived : public Base {};
int main() {
int(Derived::* _)() = &Derived::f;
}
Thanks for the quick reply. Definitely simplifies things, and I probably should have checked but was focused on my specific issue. In any case, it appears to be a bug unless someone can confirm otherwise (may be implementation defined behavior but looks very suspect and definitely inconvenient).
No one allows this case: https://godbolt.org/z/c4f5K18v1
struct Base {
private:
int f();
int f(int); // Does not compile if this is removed
};
struct Derived : public Base {};
int main() {
int(Base::* _)() = &Base::f;
}
Thanks for the feedback. Didn't really look into MitalAshok's post in too much detail (though you've changed it a bit) but my original post occurs in an SFINAE context so it's a murky area. On the surface Clang and GCC look problematic but a language lawyer may be required to settle it.
@Backl1ght Thanks for the info (does it mean it's now a confirmed bug?). Note that I reported GCC's own issue here (as described in the behavior table of my original post above). That bug was confirmed by GCC (see Andrew Pinski's response at latter link). Someone there also added a link to this Clang post in the See Also section.
Given the following code (run it here), where "Base::Whatever" is private (both overloads), why does Clang correctly display false except when (both) "T" is "Derived" and function "Whatever" is overloaded. This appears to be erroneous behavior but it's a fuzzy area in this context (but see behavior table further below):
Here's the behavior of the 3 compilers I tested (only MSVC presumably gets it right):
Unless this is explicitly mentioned in the standard somewhere, or it's considered undefined behavior (implementation defined), the call to "&T::Whatever" in the partial specialization of "HasFuncWhatever" should always presumably fail since "Whatever" is private. The primary template should therefore always kick in so the code should always display false.