public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "hello at josephloser dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/97536] New: [concepts] parser segfault for concept defined in function template Date: Fri, 23 Oct 2020 01:14:45 +0000 [thread overview] Message-ID: <bug-97536-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97536 Bug ID: 97536 Summary: [concepts] parser segfault for concept defined in function template Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hello at josephloser dot com Target Milestone: --- The code below causes a segfault when parsing a concept definition inside a function template. Note that concepts cannot be defined inside a function scope, so this should result in a useful diagnostic. Output of compiling the program with -std=c++2a: prog.cc: In function 'auto foo()': prog.cc:3:5: warning: C++20 concept definition syntax is 'concept <name> = <expr>' 3 | concept bar = true; | ^~~~~~~ prog.cc:3:13: internal compiler error: Segmentation fault 3 | concept bar = true; | ^~~ 0xc2e30f crash_signal ../../source/gcc/toplev.c:330 0x68c49c grokvardecl ../../source/gcc/cp/decl.c:10103 0x68c49c grokdeclarator(cp_declarator const*, cp_decl_specifier_seq*, decl_context, int, tree_node**) ../../source/gcc/cp/decl.c:13691 0x6913c8 start_decl(cp_declarator const*, cp_decl_specifier_seq*, int, tree_node*, tree_node*, tree_node**) ../../source/gcc/cp/decl.c:5218 0x71cc3e cp_parser_init_declarator ../../source/gcc/cp/parser.c:20934 0x6fe49c cp_parser_simple_declaration ../../source/gcc/cp/parser.c:13876 0x7002ad cp_parser_declaration_statement ../../source/gcc/cp/parser.c:13316 0x700e97 cp_parser_statement ../../source/gcc/cp/parser.c:11562 0x701e6d cp_parser_statement_seq_opt ../../source/gcc/cp/parser.c:11928 0x701f20 cp_parser_compound_statement ../../source/gcc/cp/parser.c:11878 0x718d2a cp_parser_function_body ../../source/gcc/cp/parser.c:23236 0x718d2a cp_parser_ctor_initializer_opt_and_function_body ../../source/gcc/cp/parser.c:23287 0x71c730 cp_parser_function_definition_after_declarator ../../source/gcc/cp/parser.c:29182 0x71d64f cp_parser_function_definition_from_specifiers_and_declarator ../../source/gcc/cp/parser.c:29098 0x71d64f cp_parser_init_declarator ../../source/gcc/cp/parser.c:20838 0x722c14 cp_parser_single_declaration ../../source/gcc/cp/parser.c:29669 0x722d77 cp_parser_template_declaration_after_parameters ../../source/gcc/cp/parser.c:29242 0x72337a cp_parser_explicit_template_declaration ../../source/gcc/cp/parser.c:29507 0x726cd9 cp_parser_declaration ../../source/gcc/cp/parser.c:13524 0x72726d cp_parser_translation_unit ../../source/gcc/cp/parser.c:4793 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. Wandbox link: https://wandbox.org/permlink/PKqzkXQLl3fv8ev4 For what its worth, the warning given for when a concept is defined inside a function (not a function template) could probably be improved as well. If you remove the template on `foo` such that it is just a function, the error is: prog.cc: In function 'auto foo()': prog.cc:2:5: warning: C++20 concept definition syntax is 'concept <name> = <expr>' 2 | concept bar = true; | ^~~~~~~ prog.cc:2:5: error: a non-template variable cannot be 'concept' The error message is fine, but the warning is a bit of a misnomer as `concept bar = true;` does meet the grammar of `concept <name> = <expr>`.
next reply other threads:[~2020-10-23 1:14 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-10-23 1:14 hello at josephloser dot com [this message] 2020-10-26 16:49 ` [Bug c++/97536] " mpolacek at gcc dot gnu.org 2021-03-30 15:52 ` mpolacek at gcc dot gnu.org 2021-04-19 22:06 ` cvs-commit at gcc dot gnu.org 2021-04-19 22:07 ` mpolacek at gcc dot gnu.org 2022-01-04 2:20 ` pinskia at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-97536-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).