From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id 3C523383C7D7; Wed, 14 Dec 2022 10:36:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3C523383C7D7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671014200; bh=HeLg1Iujly0aocv7fIwdc2htysJEa5SUHX7nVsA9Boo=; h=From:To:Subject:Date:From; b=yteGaQ9uDNRbndjVrxtdm+mej7Y2DyIURIv9CcxBZWUoFy54jHgs7wxm0VqRCbFIe s33RHu0p17W2xKxWliIYtCEDS9507x2wW3GwZOM3D1dVMzoSkuGQMRL4BjNJUY1v9R jYceEWOAXgqBRqwZbrYLdorTgnV9UYy9cG6w9rJo= MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4697] rust: Fix up aarch64-linux bootstrap [PR106072] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/master X-Git-Oldrev: e165214777acfe5621ad36e55b16e098d50e1596 X-Git-Newrev: 95dc11475dac06b5eecd904079de8aa94827a36a Message-Id: <20221214103640.3C523383C7D7@sourceware.org> Date: Wed, 14 Dec 2022 10:36:40 +0000 (GMT) List-Id: https://gcc.gnu.org/g:95dc11475dac06b5eecd904079de8aa94827a36a commit r13-4697-g95dc11475dac06b5eecd904079de8aa94827a36a Author: Jakub Jelinek Date: Wed Dec 14 11:35:22 2022 +0100 rust: Fix up aarch64-linux bootstrap [PR106072] Bootstrap fails on aarch64-linux and some other arches with: .../gcc/rust/parse/rust-parse-impl.h: In member function ‘Rust::AST::ClosureParam Rust::Parser::parse_closure_param() [with ManagedTokenSource = Rust::Lexer]’: .../gcc/rust/parse/rust-parse-impl.h:8916:49: error: ‘this’ pointer is null [-Werror=nonnull] The problem is that while say on x86_64-linux the side-effects in the arguments are evaluated from last argument to first, on aarch64-linux it is the other way around, from first to last. The C++ I believe even in C++17 makes the evaluation of those side-effects unordered (indeterminately sequenced with no interleaving), so that is fine. But, when the call in return statement is evaluated from first to last, std::move (pattern) happens before pattern->get_locus () and the former will make pattern (std::unique_ptr) a wrapper object around nullptr, so dereferencing it later to call get_locus () on it is invalid. 2022-12-14 Jakub Jelinek PR rust/106072 * parse/rust-parse-impl.h (parse_closure_param): Store pattern->get_locus () in a temporary before std::move (pattern) is invoked. Diff: --- gcc/rust/parse/rust-parse-impl.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index bbcbab27505..e555d93dca3 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -8912,8 +8912,9 @@ Parser::parse_closure_param () } } - return AST::ClosureParam (std::move (pattern), pattern->get_locus (), - std::move (type), std::move (outer_attrs)); + Location loc = pattern->get_locus (); + return AST::ClosureParam (std::move (pattern), loc, std::move (type), + std::move (outer_attrs)); } // Parses a grouped or tuple expression (disambiguates).