From patchwork Wed Dec 14 09:14:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1715663 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=o6gKQjXH; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NX8pJ1j7Vz23yr for ; Wed, 14 Dec 2022 20:15:03 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 072483832E52 for ; Wed, 14 Dec 2022 09:15:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 072483832E52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671009300; bh=E8Il35M1k7lWGbbjPN0OcOsXr1LDveUMSLVvPblCyto=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=o6gKQjXH9UNEg8vM/hwU8OoDRZZkY+25AdvpQrg0FEycdpxNQ10e2Zj9xprdcXEvq 8Iac36tutOp/u3KQNXlEi7a1D9Mb0Z9tK8O4ykPqiqo+g/zQhGb5G6DomHQFooJuBE tRXIBKSug9i6vv2LnaqjX7fcHovNP6k3ri1oelPQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 70A3A38330A1 for ; Wed, 14 Dec 2022 09:14:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 70A3A38330A1 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-319-8CZaTOx5POqCQYa_TY8lrA-1; Wed, 14 Dec 2022 04:14:37 -0500 X-MC-Unique: 8CZaTOx5POqCQYa_TY8lrA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7C24F858F0E; Wed, 14 Dec 2022 09:14:37 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.195.114]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3B447492C14; Wed, 14 Dec 2022 09:14:37 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 2BE9EWw61134144 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 14 Dec 2022 10:14:33 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 2BE9EWS11134143; Wed, 14 Dec 2022 10:14:32 +0100 Date: Wed, 14 Dec 2022 10:14:31 +0100 To: gcc-rust@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] rust: Fix up aarch64-linux bootstrap [PR106072] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi! 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. The following patch fixes that, ok for trunk? 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. Jakub --- gcc/rust/parse/rust-parse-impl.h.jj 2022-12-13 16:50:12.708093521 +0100 +++ gcc/rust/parse/rust-parse-impl.h 2022-12-14 09:50:31.731111932 +0100 @@ -8912,8 +8912,9 @@ Parser::parse_closur } } - 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).