This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/70971] New: ICE in parameter pack expansion


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

            Bug ID: 70971
           Summary: ICE in parameter pack expansion
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: barry.revzin at gmail dot com
  Target Milestone: ---

This may not be totally minimal, but the following code:

#include <memory>

struct A {};

template <class X, class Y, class Z>
struct B : A { };

template <class... > struct typelist {};
template <class T> struct tag { using type = T; };

template <class... Ts, class... Cs>
std::unique_ptr<A> chooseB(typelist<Cs...> )
{
    return std::unique_ptr<A>(new B<Ts...>);
}

template <class... Ts, class... Cs, class Idx, class... Rest>
std::unique_ptr<A> chooseB(typelist<Cs...> choices, Idx i, Rest... rest)
{
    auto f = [=](auto tag){
        return [=]{ return chooseB<Ts..., typename
decltype(tag)::type>(choices, rest...); };
    };

    std::function<std::unique_ptr<A>()> fs[] = {
            f(tag<Cs>{})...
    };

    return fs[i]();
}

int main() {
    auto p = chooseB(typelist<int, double, char>{}, 0, 1, 2);
}

on gcc 5.3 with g++ -std=c++1z -O2 -Wall -Wextra -Wconversion -pedantic
-pthread produced (http://coliru.stacked-crooked.com/a/8dfc904ff5476477)

main.cpp: In function 'std::unique_ptr<A> chooseB(typelist<Cs ...>, Idx, Rest
...) [with Ts = {}; Cs = {int, double, char}; Idx = int; Rest = {int, int}]':
main.cpp:29:1: error: unrecognizable insn:
 }
 ^
(insn 28 19 29 2 (set (mem/c:SI (plus:DI (reg/f:DI 82 virtual-stack-vars)
                (const_int -92 [0xffffffffffffffa4])) [65 MEM[(struct __lambda1
*)&fs + 4B]+0 S4 A32])
        (reg/v 101 [ rest#0 ])) -1
     (nil))
main.cpp:29:1: internal compiler error: in extract_insn, at recog.c:2287
libbacktrace could not find executable to open

With -g instead of -O2 it compiles but segfaults.

On clang it compiles fine.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]