[Bug c++/58353] New: Internal Compiler Error with Variadic Templates

spamjunk at stny dot rr.com gcc-bugzilla@gcc.gnu.org
Sat Sep 7 12:02:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58353

            Bug ID: 58353
           Summary: Internal Compiler Error with Variadic Templates
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: spamjunk at stny dot rr.com

bug.cpp: In instantiation of 'struct seq_t<int, 123, 5>::gen<1, 123,
123, 123, 123>':
bug.cpp:11:12:   recursively required from 'struct seq_t<int, 123,
5>::gen<4, 123>'
bug.cpp:11:12:   required from 'struct seq_t<int, 123, 5>::gen<5>'
bug.cpp:21:59:   required from 'static constexpr seq_t<E, V,
CNT>::bits_t seq_t<E, V, CNT>::init() [
with E = int; E V = 123; int CNT = 5]'
bug.cpp:30:42:   required from here
bug.cpp:11:12: internal compiler error: in tsubst, at cp/pt.c:11306
      struct gen : gen<N - 1, V, Es...>{};



Test Code:

#include <iostream>

using namespace std;

template<class E, E V, int CNT>
struct seq_t
{
     template<E... Es> struct seq{};

     template<int N, E... Es>
     struct gen : gen<N - 1, V, Es...>{};

     template<E... Es>
     struct gen<0, Es...> : seq<Es...>{};

     struct bits_t{ E e[CNT]; };

     template<E... Es>
     static constexpr bits_t init(seq<Es...>) {return {{Es...}};}

     static constexpr bits_t init() {return init(gen<CNT>{});}
};



int main()
{
     typedef seq_t<int, 123, 5> wow;

     constexpr wow::bits_t bits(wow::init());

     cout << bits.e[0] << endl;
     cout << bits.e[1] << endl;
     cout << bits.e[2] << endl;
     cout << bits.e[3] << endl;
     cout << bits.e[4] << endl;
}



More information about the Gcc-bugs mailing list