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

            Bug ID: 118060
           Summary: ICE (internal compiler error) on requires clause
           Product: gcc
           Version: 14.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ing.russomauro at gmail dot com
  Target Milestone: ---

Replicated on https://godbolt.org/z/axeTxorqW
with 13.2, 14.2, trunk versions.


SOURCE CODE:

#include <algorithm>
#include <concepts>

//template<typename T>
//concept C = true;

template<typename T>
struct S final {
    S() = default; // may remove, still internal error

    // template<C U> also internal error
    template<typename U>
    requires requires (U u){ {*(std::begin(u))} -> std::same_as<T>; }
    // internal error disappears with one of these alternatives (remove '*' or
std::begin):
    //requires requires (U u){ {std::begin(u)} -> std::same_as<T>; }
    //requires requires (U u){ {*((int*)nullptr)} -> std::same_as<T>; }
    S(const U& u) : S(){}
};

int main()
{
    S s{}; // error
    S s2{0}; // error
    S s2{0,0}; // error

    return 0;
}


MESSAGE FROM COMPILER:

<source>: In function 'int main()':
<source>:x:y: internal compiler error: Segmentation fault
   y |     requires requires (U u){ {*(std::begin(u))} -> std::same_as<T>; }
     |                              ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0x2931885 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
        ???:0
0x2948656 internal_error(char const*, ...)
        ???:0
0xb74c84 convert_to_void(tree_node*, impl_conv_void, int)
        ???:0
0xb4ec96 tsubst_requires_expr(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xb49e1a tsubst_constraint_info(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xd00dd6 do_auto_deduction(tree_node*, tree_node*, tree_node*, int,
auto_deduction_context, tree_node*, int, tree_node*)
        ???:0
0xbbd621 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int,
cp_decomp*)
        ???:0
0xce1f2a c_parse_file()
        ???:0
0xe41159 c_common_parse_file()
        ???:0


Hard to look for duplicates, seems different from:
PR92838, PR103198

Reply via email to