public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-5575] RISC-V: Fix mismatched new delete for unique_ptr
@ 2023-11-18 10:42 Kito Cheng
  0 siblings, 0 replies; only message in thread
From: Kito Cheng @ 2023-11-18 10:42 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:5f4499606ea6ab49bec30e83209db71e52d0b267

commit r14-5575-g5f4499606ea6ab49bec30e83209db71e52d0b267
Author: Kito Cheng <kito.cheng@sifive.com>
Date:   Sat Nov 18 18:37:11 2023 +0800

    RISC-V: Fix mismatched new delete for unique_ptr
    
    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.

Diff:
---
 gcc/config/riscv/riscv-target-attr.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

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));

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-11-18 10:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-18 10:42 [gcc r14-5575] RISC-V: Fix mismatched new delete for unique_ptr Kito Cheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).