https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105797
Bug ID: 105797 Summary: Internal compiler error: Segmentation fault ( fn_type_unification -> satisfaction_cache::satisfaction_cache -> iterative_hash_template_arg ) Product: gcc Version: 12.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: northon_patrick3 at yahoo dot ca Target Milestone: --- Created attachment 53061 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53061&action=edit Result from -freport-bug The code: ``` #include <type_traits> #include <concepts> template <typename T_> struct AStruct { using value_type = T_; }; template <typename T_> constexpr auto fc1(AStruct<T_> v) requires std::integral<typename std::decay_t<decltype(v)>::value_type> //requires std::integral<T_> { return v; } template <typename T1_, typename T2_> constexpr auto fc2(AStruct<T1_> v1, AStruct<T2_> v2) requires std::integral<typename std::decay_t<decltype(v1)>::value_type> { return v1; } void test(AStruct<int> v1, AStruct<int> v2) { fc2(v1, v2); } void test2(AStruct<int> v) { fc1(v); } ``` The command line: ``` g++ -std=c++20 test.cpp ``` The error: ``` test.cpp: In substitution of ‘template<class T_> constexpr auto fc1(AStruct<T_>) requires integral<typename std::decay<decltype(v)>::type::value_type> [with T_ = int]’: test.cpp:25:7: required from here test.cpp:25:14: internal compiler error: Segmentation fault 25 | { fc1(v); } | ~~~^~~ 0x1ac4724 internal_error(char const*, ...) ???:0 0x7f1693 iterative_hash_template_arg(tree_node*, unsigned int) ???:0 0x6bf9da satisfaction_cache::satisfaction_cache(tree_node*, tree_node*, sat_info) ???:0 0x81bbd4 fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node* const*, unsigned int, tree_node*, unification_kind_t, int, conversion**, bool, bool) ???:0 0x69d051 build_new_function_call(tree_node*, vec<tree_node*, va_gc, vl_embed>**, int) ???:0 0x836c31 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool, bool, int) ???:0 0x7eaa63 c_parse_file() ???:0 0x914adb c_common_parse_file() ???:0 ``` It happens from GCC 11.1 and onward to GCC 13 at commit 271072ca259dd285e7723d9bf6da7295e4090dfa. GCC is configured with: ``` configure --prefix=/opt/pat-gcc --libdir=/opt/pat-gcc/lib --libexecdir=/opt/pat-gcc/lib --enable-languages=c,c++,lto --with-isl --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-libunwind-exceptions --disable-werror gdc_include_dir=/opt/pat-gcc/include/dlang/gdc ``` If I comment out either one of test or test2 functions, it compiles. If I change either one of the requires clause to use T_ or T1_ instead of decltype, it compiles. If I change either one of fc1 or fc2 to use auto instead of a template<> clause, it compiles. So it seem to crash at a very specific condition.