[Bug libstdc++/67537] [6 Regression] r225189 breaks building boost hana

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Sep 10 13:51:00 GMT 2015


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67537

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Reduced:

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

template<typename... _Elements>
void sink(_Elements&&...);

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

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{};


This compiles with GCC but Clang gives:

c.cc:13:41: error: pack expansion contains parameter packs '_Elements' and
'_UElements' that have different lengths (1 vs. 0)
    sink( pair<_Elements, _UElements>{} ... );
               ~~~~~~~~~  ~~~~~~~~~~    ^
c.cc:41: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:42:17: note: while substituting prior template arguments into non-type
template parameter [with _UElements = <>]
      constexpr tuple(_UElements&&...) { }
                ^~~~~
c.cc:35:8: note: while substituting deduced template arguments into function
template 'tuple' [with _UElements = <>, $1 = (no value)]
struct tuple
       ^
1 error generated.

Here we get an error inside _TC<true, X> even though the true specialization
should be unreachable.



More information about the Gcc-bugs mailing list