<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - wrong template partial specialization instantiated in constexpr context"
   href="https://llvm.org/bugs/show_bug.cgi?id=24770">24770</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>wrong template partial specialization instantiated in constexpr context
          </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>Linux
          </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++11
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>zilla@kayari.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This originated at <a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67537">https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67537</a> where
Ville's additional SFINAE constraints for N4387 (improving pair and tuple v3)
cause clang to barf on libstdc++'s tuple.

This is a reduced version, which G++ accepts but Clang rejects:


template<typename T, typename U>
struct pair { };

template<typename... _Elements>
constexpr bool sink(_Elements&&...);

template<bool, typename... _Elements>
struct _TC
{
  template<typename... _UElements>
  static constexpr bool _MoveConstructibleTuple()
  {
    return sink( pair<_Elements, _UElements>{} ... );
  }
};

template<typename... _Elements>
struct _TC<false, _Elements...>
{
  template<typename... _UElements>
  static constexpr bool _MoveConstructibleTuple()
  {
    return false;
  }
};

template<bool>
struct enable_if { using type = bool; };

template<>
struct enable_if<false> { };

template<typename... _Elements>
struct tuple
{
  template<typename... _UElements> using _TMC =
        _TC<(sizeof...(_Elements) == sizeof...(_UElements)), _Elements...>;

  template<typename... _UElements, typename
           enable_if<_TMC<_UElements...>::template
_MoveConstructibleTuple<_UElements...>()>::type=true>
      constexpr tuple(_UElements&&...) { }

  constexpr tuple() { }
};

struct X { };

constexpr tuple<X> t{};


Clang says:

c.cc:13:48: error: pack expansion contains parameter packs '_Elements' and
'_UElements' that have different lengths (1 vs. 0)
    return sink( pair<_Elements, _UElements>{} ... );
                      ~~~~~~~~~  ~~~~~~~~~~    ^
c.cc:40:52: note: in instantiation of function template specialization
'_TC<true, X>::_MoveConstructibleTuple<>' requested here
           enable_if<_TMC<_UElements...>::template
_MoveConstructibleTuple<_UElements...>()>::type=true>
                                                   ^
c.cc:41:17: note: while substituting prior template arguments into non-type
template parameter [with _UElements = <>]
      constexpr tuple(_UElements&&...) { }
                ^~~~~
c.cc:34:8: note: while substituting deduced template arguments into function
template 'tuple' [with _UElements = <>, $1 = (no value)]
struct tuple
       ^
1 error generated.


The error comes from a member of _TC<true, X> but the _TMC alias template
should ensure that _TC<false, X> is used when the packs have different sizes.</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>