]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
RISC-V: Fix out of index in riscv_select_multilib_by_abi
authorYunQiang Su <syq@gcc.gnu.org>
Thu, 5 Sep 2024 11:55:20 +0000 (19:55 +0800)
committerYunQiang Su <syq@gcc.gnu.org>
Fri, 6 Sep 2024 02:18:45 +0000 (10:18 +0800)
commit b5c2aae48723c9098a8a3dab1409b30fd87bbf56
Author: YunQiang Su <yunqiang@isrc.iscas.ac.cn>
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

index 2c1ce7fc7cb8a350391cd333b077f033516986ec..bd42fd01532ba269f9510b0c0f03285505acf9fc 100644 (file)
@@ -2079,7 +2079,7 @@ riscv_select_multilib_by_abi (
   const std::string &riscv_current_abi_str,
   const std::vector<riscv_multi_lib_info_t> &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 ());