I fix the code by changing the argument type of get_riscv_ext_info to
`const char *` and the link is:
https://gcc.gnu.org/pipermail/gcc-patches/2025-May/684057.html
在 2025/5/16 10:35, Kito Cheng 写道:
Hmmmmm, it really doesn't make too much sense to get that warning, but
I can reproduce that when I compile with gcc 13 (and newer)...and
seems like a known issue [1][2]...
However I don't really like that approach, could you change the
argument type of get_riscv_ext_info to `const char *` to suppress that
warning instead?
```diff
diff --git a/gcc/common/config/riscv/riscv-common.cc
b/gcc/common/config/riscv/riscv-common.cc
index 53ca03910b3..a3105c851d6 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -214,8 +214,8 @@ static const std::unordered_map<std::string,
riscv_ext_info_t> riscv_ext_infos
#undef DEFINE_RISCV_EXT
};
-static const riscv_ext_info_t &
-get_riscv_ext_info (const std::string &ext)
+static inline const riscv_ext_info_t &
+get_riscv_ext_info (const char *ext)
{
auto itr = riscv_ext_infos.find (ext);
if (itr == riscv_ext_infos.end ())
```
[1]
https://stackoverflow.com/questions/78759847/gcc-14-possibly-dangling-reference-to-a-temporary-warning-or-not-depending-on
[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107532