https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67084
Bug ID: 67084 Summary: [c++-concepts] Matching of variable template declarations ignores constraints Product: gcc Version: c++-concepts Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: Casey at Carter dot net Target Milestone: --- Created attachment 36102 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36102&action=edit Test case The two declarations of p<T> should be distinct due to having different constraints: template <class T> constexpr bool p = true; template <class T> requires true constexpr bool p<T> = false; template <class T> requires true && false constexpr bool p<T> = true; Compiling this program with r226419 results in: ~/concept-gcc/bin/g++ -std=gnu++1z foo.cpp -c foo.cpp:10:16: error: redefinition of ‘const bool p<T>’ constexpr bool p<T> = true; ^ foo.cpp:6:16: note: ‘constexpr const bool p<T>’ previously declared here constexpr bool p<T> = false; ^ foo.cpp:10:16: internal compiler error: in set_constraints, at cp/pt.c:23421 constexpr bool p<T> = true; ^ 0x63ae8d set_constraints(tree_node*, tree_node*) ../../gcc/cp/pt.c:23421 0x673e91 process_partial_specialization ../../gcc/cp/pt.c:4728 0x675467 push_template_decl_real(tree_node*, bool) ../../gcc/cp/pt.c:5250 0x6214c4 start_decl(cp_declarator const*, cp_decl_specifier_seq*, int, tree_node*, tree_node*, tree_node**) ../../gcc/cp/decl.c:4919 0x710720 cp_parser_init_declarator ../../gcc/cp/parser.c:17728 0x7113c4 cp_parser_single_declaration ../../gcc/cp/parser.c:24892 0x71155b cp_parser_template_declaration_after_parameters ../../gcc/cp/parser.c:24509 0x712104 cp_parser_explicit_template_declaration ../../gcc/cp/parser.c:24744 0x712104 cp_parser_template_declaration_after_export ../../gcc/cp/parser.c:24762 0x718aa9 cp_parser_declaration ../../gcc/cp/parser.c:11416 0x7170fa cp_parser_declaration_seq_opt ../../gcc/cp/parser.c:11338 0x717411 cp_parser_translation_unit ../../gcc/cp/parser.c:4153 0x717411 c_parse_file() ../../gcc/cp/parser.c:34295 0x85ea22 c_common_parse_file() ../../gcc/c-family/c-opts.c:1059 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. An equivalent program with class templates or function templates overloaded similarly does compile correctly.