<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Weird failure/interaction in substitution/specialization matching"
   href="https://bugs.llvm.org/show_bug.cgi?id=38980">38980</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Weird failure/interaction in substitution/specialization matching
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>Casey@Carter.net
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Compiling this correct program with -std=c++1z:

  template<class, class> constexpr bool is_same_v = false;
  template<class T> constexpr bool is_same_v<T, T> = true;

  template<class...> using void_t = void;

  template<class T> struct id { using type = T; };

  template<class T> T val() noexcept;

  template<class X, class Y> using cond_res = 
      decltype(false ? val<const X&>() : val<const Y&>());

  template<class, class, class = void>
  struct CT { using type = void; };

  template<class D1, class D2>
  #ifndef WORKAROUND
  struct CT<D1, D2, void_t<cond_res<D1, D2>>> : id<cond_res<D1, D2>> {};
  #else
  struct CT<D1, D2, void_t<cond_res<D1, D2>>> {
      using type = cond_res<D1, D2>;
  };
  #endif

  struct S1 {};
  struct S2 : private S1 {};
  struct S3 : protected S1 {};

  static_assert(is_same_v<void, CT<S1, S2>::type>); // Fine
  static_assert(is_same_v<void, CT<S1, S3>::type>); // Error

produces diagnostices (<a href="https://godbolt.org/z/WGvIFN">https://godbolt.org/z/WGvIFN</a>):

  <source>:11:40: error: cannot cast 'const S3' to its protected base class 
  'const S1'
    decltype(false ? val<const X&>() : val<const Y&>());
                                       ^
  <source>:18:50: note: in instantiation of template type alias 'cond_res' 
  requested here
  struct CT<D1, D2, void_t<cond_res<D1, D2>>> : id<cond_res<D1, D2>> {};
                                                 ^
  <source>:30:31: note: in instantiation of template class 'CT<S1, S3, 
  void>' requested here
  static_assert(is_same_v<void, CT<S1, S3>::type>); // Error
                              ^
  <source>:27:13: note: declared protected here
  struct S3 : protected S1 {};
              ^~~~~~~~~~~~
  1 error generated.

Private base class? Fine. Protected base class? *EXPLODES*</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>