public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/100252] [9/10/11/12 Regression] Internal compiler error during template instantiation Date: Tue, 26 Apr 2022 15:54:32 +0000 [thread overview] Message-ID: <bug-100252-4-w99zZcwLO1@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-100252-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100252 --- Comment #9 from Marek Polacek <mpolacek at gcc dot gnu.org> --- When we are cp_parser_late_parsing_nsdmi for "int y = A{x}.y;" we perform finish_compound_literal on type=A, compound_literal={((struct B *) this)->x}. When digesting this initializer, we call get_nsdmi which creates a PLACEHOLDER_EXPR for A -- we don't have any object to refer to yet. After digesting, we have {.x=((struct B *) this)->x, .y=(&<PLACEHOLDER_EXPR struct A>)->x} and since we've created a PLACEHOLDER_EXPR inside it, we marked the whole ctor CONSTRUCTOR_PLACEHOLDER_BOUNDARY. f_c_l creates a TARGET_EXPR and returns TARGET_EXPR <D.2384, {.x=((struct B *) this)->x, .y=(&<PLACEHOLDER_EXPR struct A>)->x}> (*) Then we get to B b = {}; and call store_init_value, which digest the {}, which produces {.x=NON_LVALUE_EXPR <0>, .y=(TARGET_EXPR <D.2395, {.x=(&<PLACEHOLDER_EXPR struct B>)->x, .y=(&<PLACEHOLDER_EXPR struct A>)->x}>).y} The call to replace_placeholders in store_init_value will not do anything: we've marked the inner { } CONSTRUCTOR_PLACEHOLDER_BOUNDARY, and it's only a sub-expression, so replace_placeholders does nothing, so the <PLACEHOLDER_EXPR struct B> stays even though now it was the perfect time to replace it because we have an object for it: 'b'. Later, in cp_gimplify_init_expr the *expr_p is D.2395 = {.x=(&<PLACEHOLDER_EXPR struct B>)->x, .y=(&<PLACEHOLDER_EXPR struct A>)->x} where D.2395 is of type A, but we crash because we hit <PLACEHOLDER_EXPR struct B>, which has a different type. Now here's an idea how we could fix this: at the (*) point in finish_compound_literal we could replace <PLACEHOLDER_EXPR struct A> with D.2384 because now we have an object! Then clear CONSTRUCTOR_PLACEHOLDER_BOUNDARY, because we no longer have a PLACEHOLDER_EXPR in the {}. Then store_init_value will be able to replace <PLACEHOLDER_EXPR struct B> with 'b', and we should be good to go.
next prev parent reply other threads:[~2022-04-26 15:54 UTC|newest] Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-04-25 3:08 [Bug c++/100252] New: " sand at rifkin dot dev 2021-04-25 15:31 ` [Bug c++/100252] " sand at rifkin dot dev 2021-04-26 0:47 ` sand at rifkin dot dev 2021-04-26 7:28 ` rguenth at gcc dot gnu.org 2021-04-26 14:37 ` [Bug c++/100252] [8/9/10/11/12 Regression] " mpolacek at gcc dot gnu.org 2021-04-26 21:11 ` ppalka at gcc dot gnu.org 2021-04-30 8:10 ` rguenth at gcc dot gnu.org 2021-05-14 9:54 ` [Bug c++/100252] [9/10/11/12 " jakub at gcc dot gnu.org 2021-06-01 8:20 ` rguenth at gcc dot gnu.org 2022-04-25 22:43 ` mpolacek at gcc dot gnu.org 2022-04-26 15:54 ` mpolacek at gcc dot gnu.org [this message] 2022-04-26 15:58 ` mpolacek at gcc dot gnu.org 2022-04-26 22:46 ` mpolacek at gcc dot gnu.org 2022-05-25 15:01 ` [Bug c++/100252] [9/10/11/12/13 " cvs-commit at gcc dot gnu.org 2022-05-25 15:03 ` [Bug c++/100252] [9/10/11/12 " mpolacek at gcc dot gnu.org 2022-05-27 9:45 ` [Bug c++/100252] [10/11/12 " rguenth at gcc dot gnu.org 2022-06-28 10:44 ` jakub at gcc dot gnu.org 2022-07-01 16:12 ` mpolacek at gcc dot gnu.org 2023-07-07 10:39 ` [Bug c++/100252] [11/12 " rguenth 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-100252-4-w99zZcwLO1@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).