From patchwork Thu Sep 5 11:58:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YunQiang Su X-Patchwork-Id: 1981213 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=LGU5pajj; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WzyZs49WPz1ynq for ; Thu, 5 Sep 2024 21:59:33 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5D4253865C26 for ; Thu, 5 Sep 2024 11:59:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5D4253865C26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1725537571; bh=CdbyRyeJwZEsBE8EfFZTmWTKKPWl4801hcgfgKKDqS0=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=LGU5pajjlA3UESiKnjMtPoXxbe91F1ar9AB0rBkX4PkHdSVWB/pWqxPHimJKslzNh l8dM4L1fVMCoivVfqVcgV4Xr+6d3Da7/71H9qOXqA5Rthw+BpDbQILY3ZHroldEAwJ E0Qd4ttxPmuaXAsn5eXgMCi9hHjFxaK8PEeVjqgM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-oo1-f42.google.com (mail-oo1-f42.google.com [209.85.161.42]) by sourceware.org (Postfix) with ESMTPS id DC7BC386481D; Thu, 5 Sep 2024 11:58:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DC7BC386481D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DC7BC386481D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.161.42 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725537537; cv=none; b=KKg901fJUTGhTUjRU1hRRDb3r5DintPWGPsPGwRZGRbB7ybW2WmH9FXmGvLwLQ880GHSTq4+M8J13PaBGPRNb+HyyggpaUaLIiZxSYjm64bVDvfSPYqEWydJiJQ0WqC0LLB5ZEqF9OREGjAP9dmBx54iDQpHbaZwZIwfrEwaNTs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725537537; c=relaxed/simple; bh=Wk8pxUU7yoCfvwz5e27f8TVt16PaFX3oAu3YXJkaMlY=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=o3sf0LNGNeQ7oqQqYxRwW8ogS0RV8tnQkJQF7GHE8wBsR9pgONYeqzQ0iXP1yYhalHvoJ5i5CPkPoS2WiljXCwFfjFyRwuj3hluYmo757+gSzL64WKw7PY+AIlhrFNq4sC+aL0UeMkCleUGmJLIRsKfidCjVhFhlD6eWaU0byhg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oo1-f42.google.com with SMTP id 006d021491bc7-5dfabdbef52so448442eaf.3; Thu, 05 Sep 2024 04:58:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725537530; x=1726142330; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=CdbyRyeJwZEsBE8EfFZTmWTKKPWl4801hcgfgKKDqS0=; b=q1c1CQqzn2MJ7TcTmy971mIazPzoFOYq4o5kB+Jgpa6tH+8FOkBCqR+I1+pLV040ND iQkXmYETjdJ3PHLp0tY0mMMJKHJHOwYyImTJ5fUZorybGbbLLAWb2taRN7ji/HvSNIaG p7dleXz68nwOeb8BgMtcSZk+uok54/M7ainGCHD21b/HDhLq/r6RWCRL3W77CBuUIfQT P4vgMM3us1AscxtbeXjYyMyVj8tricCYZHzRTtgZjB/7h6qBv+3kn8p6/ElMCAJAOYJ/ jnBcXrhl/eYFl2ID4m1baIZIsqHhFpeX/mfloI8a0xIOATM+7gKxk9wG4qkAIQVj/tfv aJ/w== X-Forwarded-Encrypted: i=1; AJvYcCXqO/XbB3QNuKIvF85DmMMTX8yC0QVg/YoVnLvdzvDO+UA2UIrZNl41PtdDlc/cU1o4w5M=@gcc.gnu.org X-Gm-Message-State: AOJu0YwSvS9542ppigv2p4lPSFt14ianMyn/CxpgIoUX5jc/f1hlHvkK WrP07HfgxIxrEj4+SdG/A60eqUxWlJJHM2MKiQoXHgoimUqnt6PXxH6iiOFI X-Google-Smtp-Source: AGHT+IFHpZiqJteYblSf/s6AoJIwkVYB5ro/kb6nN0yGlVG2+fqK8PNo4qzPy8d4lBVlh+nKCwmw+A== X-Received: by 2002:a05:6359:5f89:b0:1b5:ec84:f034 with SMTP id e5c5f4694b2df-1b7f1b1d7cfmr2282064055d.24.1725537529839; Thu, 05 Sep 2024 04:58:49 -0700 (PDT) Received: from localhost.localdomain ([194.169.55.179]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7d4fbda77d5sm3240488a12.71.2024.09.05.04.58.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 05 Sep 2024 04:58:49 -0700 (PDT) From: YunQiang Su To: gcc-patches@gcc.gnu.org Cc: kito.cheng@gmail.com, palmer@dabbelt.com, andrew@sifive.com, jim.wilson.gcc@gmail.com, YunQiang Su Subject: [PATCH] RISC-V: Fix out of index in riscv_select_multilib_by_abi Date: Thu, 5 Sep 2024 19:58:43 +0800 Message-Id: <20240905115843.75100-1-syq@gcc.gnu.org> X-Mailer: git-send-email 2.39.3 (Apple Git-146) MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org commit b5c2aae48723c9098a8a3dab1409b30fd87bbf56 Author: YunQiang Su Date: Thu Sep 5 15:14:43 2024 +0800 RISC-V: Lookup reversely in riscv_select_multilib_by_abi The last element should use index multilib_infos.size () - 1 gcc * common/config/riscv/riscv-common.cc(riscv_select_multilib_by_abi): Fix out of index problem. --- gcc/common/config/riscv/riscv-common.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc index 2c1ce7fc7cb..bd42fd01532 100644 --- a/gcc/common/config/riscv/riscv-common.cc +++ b/gcc/common/config/riscv/riscv-common.cc @@ -2079,7 +2079,7 @@ riscv_select_multilib_by_abi ( const std::string &riscv_current_abi_str, const std::vector &multilib_infos) { - for (ssize_t i = multilib_infos.size (); i >= 0; --i) + for (ssize_t i = multilib_infos.size () - 1; i >= 0; --i) if (riscv_current_abi_str == multilib_infos[i].abi_str) return xstrdup (multilib_infos[i].path.c_str ());