Oh…you are hero! I thought strncpy will put a null there until I saw this patch and google it!
LGTM! Kuan-Lin Chen <[email protected]>於 2025年11月12日 週三,15:34寫道: > Fix the random error in gcc.target/riscv/target-attr-06.c. > > gcc/ChangeLog: > > * config/riscv/riscv-target-attr.cc (riscv_process_target_str): > Clean > the final byte of str_to_check. > > --- > gcc/config/riscv/riscv-target-attr.cc | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/gcc/config/riscv/riscv-target-attr.cc > b/gcc/config/riscv/riscv-target-attr.cc > index 54edeebf93c..15b4a932502 100644 > --- a/gcc/config/riscv/riscv-target-attr.cc > +++ b/gcc/config/riscv/riscv-target-attr.cc > @@ -371,6 +371,7 @@ riscv_process_target_str (string_slice args, > > std::unique_ptr<char[]> buf (new char[len+1]); > char *str_to_check = buf.get (); > + memset(str_to_check + len, 0, 1); > strncpy (str_to_check, args.begin (), args.size ()); > > /* Used to catch empty spaces between semi-colons i.e. > -- > 2.34.1 > >
