[committed] RISC-V: Fix mismatched new delete for unique_ptr

Message ID 20231118104248.11513-1-kito.cheng@sifive.com
State Unresolved
Headers
Series [committed] RISC-V: Fix mismatched new delete for unique_ptr |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Kito Cheng Nov. 18, 2023, 10:42 a.m. UTC
  gcc/ChangeLog:

	* config/riscv/riscv-target-attr.cc
	(riscv_target_attr_parser::parse_arch): Use char[] for
	std::unique_ptr to prevent mismatched new delete issue.
	(riscv_process_one_target_attr): Ditto.
	(riscv_process_target_attr): Ditto.
---
 gcc/config/riscv/riscv-target-attr.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
  

Patch

diff --git a/gcc/config/riscv/riscv-target-attr.cc b/gcc/config/riscv/riscv-target-attr.cc
index 78f259d0c96..c4bd99d8632 100644
--- a/gcc/config/riscv/riscv-target-attr.cc
+++ b/gcc/config/riscv/riscv-target-attr.cc
@@ -105,7 +105,7 @@  riscv_target_attr_parser::parse_arch (const char *str)
     {
       /* Parsing the extension list like "+<ext>[,+<ext>]*".  */
       size_t len = strlen (str);
-      std::unique_ptr<char> buf (new char[len]);
+      std::unique_ptr<char[]> buf (new char[len]);
       char *str_to_check = buf.get ();
       strcpy (str_to_check, str);
       const char *token = strtok_r (str_to_check, ",", &str_to_check);
@@ -241,7 +241,7 @@  riscv_process_one_target_attr (char *arg_str,
       return false;
     }
 
-  std::unique_ptr<char> buf (new char[len]);
+  std::unique_ptr<char[]> buf (new char[len]);
   char *str_to_check = buf.get();
   strcpy (str_to_check, arg_str);
 
@@ -327,7 +327,7 @@  riscv_process_target_attr (tree args, location_t loc, struct gcc_options *opts)
       return false;
     }
 
-  std::unique_ptr<char> buf (new char[len]);
+  std::unique_ptr<char[]> buf (new char[len]);
   char *str_to_check = buf.get ();
   strcpy (str_to_check, TREE_STRING_POINTER (args));