The following code segfaults on gcc 7 and gcc 8. It seems to be fixed in gcc 9, but a variant of the following code still segfault on gcc 9 and 10. ```c++ #include <functional> #include <iostream> namespace ranges { struct view_interface { template < bool = true > operator bool(); #if 1 template < bool B = true> requires false operator bool(); // ICE on gcc <= 10 #elif 1 template < bool B = true> requires false explicit operator bool(); // ICE on gcc <= 8. This code is working since gcc 9. #else template < bool B = true, std::enable_if_t<B>> explicit operator bool(); // a possible workaround #endif }; template < typename View > struct impl { template < typename... Ts, typename V = View > static auto bind(Ts... ts) -> decltype(V::bind((ts)...)); }; template < typename > struct view; template < typename Fun > view< Fun > make_view(Fun); template < typename View > struct view { template < typename Arg, typename Pipe > friend auto operator|(Arg, Pipe) -> decltype(Pipe::pipe(std::declval< Arg >, std::declval< Pipe >())); View view_; template < typename Rng, typename Vw > static auto pipe(Rng, Vw v) { return v.view_(0); } template < typename... Ts, typename V = View > auto operator()(Ts... ts) -> decltype(make_view(impl< V >::bind(view_, (ts)...))); }; struct f { template < typename g > static auto bind(f h, g t) { return std::bind(h, std::placeholders::_1, t); } template < typename a, typename ValRng > auto operator()(a, ValRng) -> view_interface; }; view< f > join; } std::string e() { std::vector< std::string > extensions; std::string i; auto o = extensions | ranges::join(i); std::cout << o; } ``` This will produce this error: ```terminal > g++-9 -std=c++17 -fconcepts -c ice.cpp' ice.cpp: In function ‘std::string e()’: ice.cpp:53:16: internal compiler error: Segmentation fault 53 | std::cout << o; | ^ Please submit a full bug report, with preprocessed source if appropriate. See <https://bugs.archlinux.org/> for instructions. ``` Tested compiler versions are: ```terminal > g++-7 --version g++-7 (GCC) 7.4.1 20181207 Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. > g++-8 --version g++-8 (GCC) 8.3.0 Copyright (C) 2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. > g++-9 --version g++ (GCC) 9.1.0 Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. > g++-git --version g++-git (GCC) 10.0.0 20190709 (experimental) Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ```
I can confirm that, for the provided snippet, all releases fail for me.
This still fails and furthermore fails in `-std=c++2a` mode as well.
On gcc-10 I get now the following stacktrace: ``` g++-git -std=c++17 -fconcepts -c ice.cpp main.cpp: In function ‘std::string e()’: main.cpp:46:16: internal compiler error: Segmentation fault 46 | std::cout << o; | ^ 0xc5b15f crash_signal /home/marehr/Packages/gcc-git/src/gcc/gcc/toplev.c:328 0x645182 compare_ics /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/call.c:10538 0x648c84 joust /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/call.c:11191 0x649cbc tourney /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/call.c:11630 0x649fd1 build_user_type_conversion_1 /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/call.c:4165 0x64b435 implicit_conversion /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/call.c:2053 0x64baf0 good_conversion(tree_node*, tree_node*, tree_node*, int, int) /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/call.c:2093 0x77183e check_non_deducible_conversion /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/pt.c:21173 0x77183e check_non_deducible_conversions /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/pt.c:20645 0x77183e fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node* const*, unsigned int, tree_node*, unification_kind_t, int, conversion**, bool, bool) /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/pt.c:20947 0x64e879 add_template_candidate_real /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/call.c:3394 0x64f046 add_template_candidate /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/call.c:3479 0x64f046 add_candidates /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/call.c:5805 0x64f612 add_candidates /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/call.c:5720 0x64f612 add_operator_candidates /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/call.c:5909 0x6545eb build_new_op_1 /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/call.c:6132 0x6551ed build_new_op(op_location_t const&, tree_code, int, tree_node*, tree_node*, tree_node*, tree_node**, int) /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/call.c:6520 0x7a563a build_x_binary_op(op_location_t const&, tree_code, tree_node*, tree_code, tree_node*, tree_code, tree_node**, int) /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/typeck.c:4245 0x70c7ad cp_parser_binary_expression /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/parser.c:9650 0x70d575 cp_parser_assignment_expression /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/parser.c:9785 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://bugs.archlinux.org/> for instructions ```
Compiles without crashing since r10-6926. That commit added a test, but this one is valid.
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>: https://gcc.gnu.org/g:4f0aa5b051c0d3e81478bcb495e4e072b2d9827d commit r11-3268-g4f0aa5b051c0d3e81478bcb495e4e072b2d9827d Author: Marek Polacek <polacek@redhat.com> Date: Thu Sep 17 15:31:50 2020 -0400 c++: Add tests for fixed PRs. Bugzilla inspection turned up a bunch of old(er) PRs that have been fixed. Let's include them not to regress in the future. gcc/testsuite/ChangeLog: PR c++/87530 PR c++/58156 PR c++/68828 PR c++/86002 PR c++/91525 PR c++/96223 PR c++/87032 PR c++/35098 * g++.dg/cpp0x/move-return4.C: New test. * g++.dg/cpp0x/vt-58156.C: New test. * g++.dg/cpp2a/concepts-pr68828.C: New test. * g++.dg/cpp2a/concepts-pr86002.C: New test. * g++.dg/cpp2a/concepts-pr91525.C: New test. * g++.dg/cpp2a/constexpr-indeterminate1.C: New test. * g++.dg/cpp2a/desig17.C: New test. * g++.dg/ext/attrib62.C: New test.
Fixed.