public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-1660] c++: fix 32-bit spaceship failures [PR110185] Date: Fri, 9 Jun 2023 15:42:02 +0000 (GMT) [thread overview] Message-ID: <20230609154202.8D6A9385C6CA@sourceware.org> (raw) https://gcc.gnu.org/g:953bbeaeff050f4d0b670568a587aa1ce82ed711 commit r14-1660-g953bbeaeff050f4d0b670568a587aa1ce82ed711 Author: Jason Merrill <jason@redhat.com> Date: Fri Jun 9 10:37:35 2023 -0400 c++: fix 32-bit spaceship failures [PR110185] Various spaceship tests failed after r14-1624. This turned out to be because the comparison category classes return in memory on 32-bit targets, and the synthesized operator<=> looks something like if (auto v = a.x <=> b.x, v == 0); else return v; if (auto v = a.y <=> b.y, v == 0); else return v; etc. so check_return_expr was trying to do NRVO for all the 'v' variables, and now on subsequent returns we check to see if the previous NRV is still in scope. But the NRVs didn't have names, so looking up name bindings crashed. Fixed both by giving 'v' a name so we can NRVO the first one, and fixing the test to give up if the old NRV has no name. PR c++/110185 PR c++/58487 gcc/cp/ChangeLog: * method.cc (build_comparison_op): Give retval a name. * typeck.cc (check_return_expr): Fix for nameless variables. Diff: --- gcc/cp/method.cc | 1 + gcc/cp/typeck.cc | 1 + 2 files changed, 2 insertions(+) diff --git a/gcc/cp/method.cc b/gcc/cp/method.cc index 0c2ca9e4f41..91cf943f110 100644 --- a/gcc/cp/method.cc +++ b/gcc/cp/method.cc @@ -1679,6 +1679,7 @@ build_comparison_op (tree fndecl, bool defining, tsubst_flags_t complain) if (defining) { tree var = create_temporary_var (rettype); + DECL_NAME (var) = get_identifier ("retval"); pushdecl (var); cp_finish_decl (var, comp, false, NULL_TREE, flags); comp = retval = var; diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc index 11927cbdf83..da591dafc8f 100644 --- a/gcc/cp/typeck.cc +++ b/gcc/cp/typeck.cc @@ -11174,6 +11174,7 @@ check_return_expr (tree retval, bool *no_warning) current_function_return_value = bare_retval; else if (current_function_return_value && VAR_P (current_function_return_value) + && DECL_NAME (current_function_return_value) && !decl_in_scope_p (current_function_return_value)) { /* The earlier NRV is out of scope at this point, so it's safe to
reply other threads:[~2023-06-09 15:42 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20230609154202.8D6A9385C6CA@sourceware.org \ --to=jason@gcc.gnu.org \ --cc=gcc-cvs@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).