https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80667
Bug ID: 80667 Summary: [c++1z] ice segfault on partial specialization with non-type template parameter Product: gcc Version: 7.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mathias at gaunard dot com Target Milestone: --- Building the following code with std=c++1z #include <type_traits> template<class T> struct traits { static constexpr T const_min = 0; }; template <typename T, typename> class Impl; template<typename T, T MaxValue> struct Impl<T, std::integral_constant<T, MaxValue>> { }; template<typename T> struct Impl<T, std::integral_constant<T, traits<T>::const_min>> { }; Impl<unsigned char, std::integral_constant<unsigned char, 0>> foo() { return {}; } gives test.cpp: In function ‘Impl<unsigned char, std::integral_constant<unsigned char, 0> > foo()’: test.cpp:22:67: internal compiler error: Segmentation fault Impl<unsigned char, std::integral_constant<unsigned char, 0>> foo() ^ 0xb118ef crash_signal ../../gcc-src/gcc/toplev.c:337 0x61b925 unify ../../gcc-src/gcc/cp/pt.c:20292 0x61c8d1 unify ../../gcc-src/gcc/cp/pt.c:20573 0x61c319 unify ../../gcc-src/gcc/cp/pt.c:20764 0x61c4d7 unify ../../gcc-src/gcc/cp/pt.c:20843 0x61c319 unify ../../gcc-src/gcc/cp/pt.c:20764 0x61d971 get_partial_spec_bindings ../../gcc-src/gcc/cp/pt.c:21561 0x61db83 more_specialized_partial_spec ../../gcc-src/gcc/cp/pt.c:21436 0x61ddd9 most_specialized_partial_spec ../../gcc-src/gcc/cp/pt.c:21856 0x62e66b instantiate_class_template_1 ../../gcc-src/gcc/cp/pt.c:10230 0x62e66b instantiate_class_template(tree_node*) ../../gcc-src/gcc/cp/pt.c:10798 0x691e75 complete_type(tree_node*) ../../gcc-src/gcc/cp/typeck.c:133 0x5ecffc check_function_type ../../gcc-src/gcc/cp/decl.c:14662 0x5ecffc start_preparsed_function(tree_node*, tree_node*, int) ../../gcc-src/gcc/cp/decl.c:14883 0x6000f3 start_function(cp_decl_specifier_seq*, cp_declarator const*, tree_node*) ../../gcc-src/gcc/cp/decl.c:15199 0x686c97 cp_parser_function_definition_from_specifiers_and_declarator ../../gcc-src/gcc/cp/parser.c:26129 0x686c97 cp_parser_init_declarator ../../gcc-src/gcc/cp/parser.c:19159 0x68796d cp_parser_simple_declaration ../../gcc-src/gcc/cp/parser.c:12777 0x688575 cp_parser_block_declaration ../../gcc-src/gcc/cp/parser.c:12602 0x666ec4 cp_parser_declaration ../../gcc-src/gcc/cp/parser.c:12500 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. Works fine without std=c++1z, alternatively a workaround is to add a cast in the second partial specialization.