public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "lundberj at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/55708] New: g++ crashes: constexpr function with reference parameters. Date: Sat, 15 Dec 2012 13:00:00 -0000 [thread overview] Message-ID: <bug-55708-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55708 Bug #: 55708 Summary: g++ crashes: constexpr function with reference parameters. Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: lundberj@gmail.com The following code crashes g++ 4.8-20121209 (and gcc 4.7.2). The issue occurs with some uses of the result of a constexpr function with reference parameters (&& or &). Both the normal template do_y() and user defoned literal _y() shows exactly the same problem, via the assert at cp/pt.c:14334. Perhaps related: bug 49514, http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49514 Full example: template<int N,int NNN> struct AA { static constexpr int val = N; }; template<typename A,typename B> //constexpr unsigned long long mymax(A a,B b){ // <-- compiles constexpr unsigned long long mymax(A && a,const B& b){ return a<b?b:a; } template<char... List> constexpr long long operator"" _y() noexcept { return AA<1, mymax(1,2)>::val; // <-- crashes gcc // return mymax(1,2); // <-- compiles // return AA<1,2>::val; // <-- compiles } template<char... List> constexpr unsigned long long do_y() noexcept { return AA<1, mymax(1,2)>::val; <-- crashes gcc } int main(){ return 1_y + do_y() ; } I compiled with g++ -Wall -Wextra file.cpp -std=c++11 Here's the full g++ printout: In function ‘constexpr long long int operator"" _y()’: internal compiler error: in tsubst_copy_and_build, at cp/pt.c:14334 return AA<1, mymax(1,2)>::val; ^ 0x81a4dc9 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ../.././gcc/cp/pt.c:14334 0x81ed922 tsubst_non_call_postfix_expression ../.././gcc/cp/pt.c:13229 0x81a0422 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ../.././gcc/cp/pt.c:13452 0x81a0a99 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ../.././gcc/cp/pt.c:13352 0x81a1439 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ../.././gcc/cp/pt.c:13760 0x81a5c3a fold_non_dependent_expr_sfinae(tree_node*, int) ../.././gcc/cp/pt.c:5081 0x81c48bd convert_nontype_argument ../.././gcc/cp/pt.c:5493 0x81c48bd convert_template_argument ../.././gcc/cp/pt.c:6383 0x81ca30b coerce_template_parms ../.././gcc/cp/pt.c:6722 0x81cc506 lookup_template_class_1 ../.././gcc/cp/pt.c:7226 0x81cc506 lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*, int, int) ../.././gcc/cp/pt.c:7523 0x82dbc87 finish_template_type(tree_node*, tree_node*, int) ../.././gcc/cp/semantics.c:2791 0x8267f40 cp_parser_template_id ../.././gcc/cp/parser.c:12707 0x826834a cp_parser_class_name ../.././gcc/cp/parser.c:18105 0x825cf49 cp_parser_qualifying_entity ../.././gcc/cp/parser.c:5276 0x825cf49 cp_parser_nested_name_specifier_opt ../.././gcc/cp/parser.c:5007 0x8275975 cp_parser_simple_type_specifier ../.././gcc/cp/parser.c:13882 0x825be2a cp_parser_postfix_expression ../.././gcc/cp/parser.c:5551 0x825e5ab cp_parser_unary_expression ../.././gcc/cp/parser.c:6686 0x825f185 cp_parser_binary_expression ../.././gcc/cp/parser.c:7360
next reply other threads:[~2012-12-15 13:00 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-12-15 13:00 lundberj at gmail dot com [this message] 2013-04-26 11:52 ` [Bug c++/55708] " paolo.carlini at oracle dot com 2013-04-26 12:19 ` paolo.carlini at oracle dot com
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-55708-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).