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

            Bug ID: 122269
           Summary: Error on constexpr structured binding using tuple
                    protocol
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tkaminsk at gcc dot gnu.org
  Target Milestone: ---

GCC produces error `error: '<anonymous>' is not a constant expression` when
compiling following code:
```
#include <utility>
using std::size_t;

  template<size_t _Num>
  struct _IndexPack
  {
    template<size_t _Idx>
      static consteval size_t
      get() noexcept
      { return _Idx; }
  };

  template<size_t _Num>
    struct std::tuple_size<_IndexPack<_Num>>
    { static constexpr size_t value = _Num; };

  template<size_t _Idx, size_t _Num>
    struct std::tuple_element<_Idx, _IndexPack<_Num>>
    { using type = size_t; };

template<size_t N>
void foo()
{
  constexpr auto [...ids] = _IndexPack<N>();
  static_assert( sizeof...(ids) == N );
}

int main() {
    foo<4>();
}
```
https://godbolt.org/z/Kvv5fxjWb

Reply via email to