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

    <tr>
        <th>Summary</th>
        <td>
            "protected" bug in template partial specialization
        </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>
    Hi there,

The (minimal) C++ code below succeeds in the latest versions of GCC and MSVC but fails to compile in Clang 18.1 (the latest version at this writing - haven't tested earlier versions). You can run the code [here](https://godbolt.org/z/rE9nYPE9c) (identical to code below).

The issue is that "_Test::Whatever_" is "_protected_" so it fails at the "_BaseClass_" line below (in the partial specialization) but if "_Test::Whatever_" is made "_private_" then the code (strangely) succeeds. It should work even if "_protected_" of course (one would think) since SFINAE should fail in the partial specialization of "_TestTemplate_" (because "_Test::Whatever_" is protected) so the "_BaseClass_" code should never even kick in in theory (at that point in the code). This all gets into a fuzzy area however (best left to the compiler specialists) but since it works for GCC and MSVC and (more importantly) it works even in Clang if "_Test::Whatever_" is made "_private_" as noted (but not "_protected_"), then something clearly doesn't look right (unless undefined behaviour comes into play but locating the precise clause in the standard would be non-trivial).

```
#include <type_traits>

class Test
{
protected:
    int Whatever();
};

template <typename T>
struct BaseClass : std::true_type
{
};

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

template <typename T>
struct TestTemplate<T,
 std::void_t<decltype(&T::Whatever)>
                   >  : BaseClass<decltype(&T::Whatever)>
{
};

int main()
{
 constexpr bool val = TestTemplate<Test>::value;

    return 0;
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVk1v4zYQ_TX0ZRDDpvylgw-xY3f30KLAGi32FIyoscWGIg1yZK_z6wtSkhN722w_gkCRFM7Me2_ekMIQ9MESLcV0JaZPA2y4cn75ib5hqQ_1l0tgqsOgcO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