<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/107629>107629</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            "private" access specifier not respected in overloaded SFINAE context
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          HexadigmSystems
      </td>
    </tr>
</table>

<pre>
    Given the following code (run it [here](https://godbolt.org/z/WTdbqdjc5)), where "Base::Whatever" is private (both overloads), why does Clang correctly display false except when "T" is "_true_" and function "_Whatever_" is overloaded. This appears to be erroneous behavior but it's a fuzzy area in this context (but see behavior tables further below):

```

#include <type_traits>
#include <iostream>

class Base
{
private: // Defaults to this anyway but being explicit

    void Whatever(int)
    {
    }

 void Whatever(int, float)
    {
    }
};

class Derived : public Base
{
};

template <typename T, typename U, typename = void>
struct HasFuncWhatever : std::false_type
{
};

template <typename T, typename U>
struct HasFuncWhatever<T,
 U,
                       std::void_t<decltype(static_cast<U T::*>(&T::Whatever))>
                      >
                      : std::true_type
{
};

int main()
{
    using T = Derived;
    using U = void (int);
    std::cout << HasFuncWhatever<T, U>::value;
    return 0;
}

```

Here's the behavior of the 3 compilers I tested (only MSVC presumably gets it right):

Clang behavior

```
T          "Whatever" overloaded?   Clang Displays MSVC Displays     GCC Displays       
-          ---------------------- --------          --------          --------           
Base       No false (correct)   false (correct)   false (correct) 
Base       Yes                      false (correct)   false (correct) Fails compilation due to private access (incorrect)
Derived    No false (correct)   false (correct)   false (incorrect) 
Derived    Yes                      true (incorrect)  false (correct) Fails compilation due to private access (incorrect)

```

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.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.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