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

            Bug ID: 78785
           Summary: Internal compiler error: segmentation fault - mixin
                    based on lambdas
           Product: gcc
           Version: 6.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: michele.caini at gmail dot com
  Target Milestone: ---

The following snippet doesn't compile.
GCC 6.1.0 stops working with an ICE due to a segfault.
It works with GCC 6.2 and GCC 7.

---

template<int I> struct tag: tag<I-1> {};
template<> struct tag<0> {};

template<typename...>
struct B;

template<typename F, typename... O>
struct B<F, O...>: F, B<O...> {
    B(F f, O... o): F{f}, B<O...>(o...) {}
    using B<O...>::operator();
    template<typename... A>
    void operator()(tag<sizeof...(O)>, A... a) { F::operator()(a...); }
};

template<>
struct B<> { void operator()(); };

template<typename... F>
struct S: B<F...> {
    S(F... f): B<F...>{f...} {}
    template<typename... A>
    void operator()(A... a) { B<F...>::operator()(tag<sizeof...(F)>{}, a...); }
};

int main() {
    auto l1 = [](auto){};
    auto l2 = [](auto){};
    S<decltype(l1), decltype(l2)> s{l1, l2};
    s(42);
}

Reply via email to