[Bug c++/106980] New: Concept on a variadig template

spiegelneuron at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Sep 20 15:57:30 GMT 2022


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

            Bug ID: 106980
           Summary: Concept on a variadig template
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: spiegelneuron at gmail dot com
  Target Milestone: ---

The following code compiles fine with the current version of VC++ 2022:

#include <iostream>
#include <utility>

using namespace std;

template<size_t N, typename ... Fns>
#if defined(_MSC_VER)
    requires (N >= 1) && (requires( Fns fn ) { { fn.template operator
()<(size_t)N - 1>() } -> std::same_as<void>; } && ...)
#elif defined(__GNUC__)
    requires (N >= 1) && (requires( Fns ... fn ) { { fn.template operator
()<(size_t)N - 1>() } -> std::same_as<void>; } && ...)
#endif
void unroll( Fns ... fns )
{
    auto unroll_n = [&]<typename Fn, size_t ... Indices>( Fn fn,
std::index_sequence<Indices ...> )
    {
        (fn.template operator ()<Indices>(), ...);
    };
    (unroll_n( fns, std::make_index_sequence<N>() ), ...);
}

int main()
{
    unroll<3>(
        []<size_t I>() { cout << "hello " << I << endl; },
        []<size_t I>() { cout << "this " << I << endl; },
        []<size_t I>() { cout << "world " << I << endl; } );
}

g++ 11.2.0 crashes.


More information about the Gcc-bugs mailing list