https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85908
Bug ID: 85908 Summary: Internal error with concepts and polymorphic lambdas Product: gcc Version: 8.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: josedaniel.garcia at uc3m dot es Target Milestone: --- Using a polymorphic lambda with a concept causes an internal error. I have tried with g++7 and g++8 when compiling with -fconcepts Source code #include <iostream> #include <type_traits> #include <vector> template <typename T> struct value_type { using type = typename T::value_type; }; template <typename T> struct value_type<T*> { using type = T; }; template <typename T, std::size_t N> struct value_type<T[N]> { using type = T; }; template <typename T> using value_type_t = typename value_type<std::decay_t<T>>::type; template <typename T> struct iterator_type { using type = typename T::iterator; }; template <typename T> using iterator_type_t = typename iterator_type<std::decay_t<T>>::type; template <typename R> concept bool Range = requires(R r) { typename iterator_type_t<R>; { r.begin() } -> iterator_type_t<R>; }; template <typename C, typename R> concept bool Combiner = Range<R> && requires(value_type_t<R> x, value_type_t<R> y, C && c) { { c(x,y) } -> value_type_t<R>; }; //template <Range R, Combiner<R> C> template <typename R, typename C> requires Combiner<C,R> auto reduce(const R & r, C && c) { auto it = r.begin(); auto s = *it; while (it++ != r.end()) { s = c(s,*it); } return s; }; int main() { std::vector<int> v{1,2,3}; std::cout << "r=" << reduce(v,[](auto x, int y) { return x+y; }); return 0; } Compiler output: <source>: In instantiation of 'main()::<lambda(auto:1, int)> [with auto:1 = int]': <source>:42:8: required from here <source>:57:65: internal compiler error: Segmentation fault std::cout << "r=" << reduce(v,[](auto x, int y) { return x+y; }); ^ mmap: Cannot allocate memory Please submit a full bug report, with preprocessed source if appropriate. See <https://gcc.gnu.org/bugs/> for instructions. Compiler returned: 1