]> git-server-git.apps.pok.os.sepia.ceph.com Git - googletest.git/commitdiff
Workaround GCC 12 -Wrestrict false-positive
authorDerek Mauro <dmauro@google.com>
Wed, 10 Jul 2024 16:14:40 +0000 (09:14 -0700)
committerCopybara-Service <copybara-worker@google.com>
Wed, 10 Jul 2024 16:15:21 +0000 (09:15 -0700)
Suggested workaround from https://github.com/Nekto89/googletest/commit/751760ad543f205e1d76797bcc5c7e2ca0c30cce

Fixes #4570

PiperOrigin-RevId: 651044944
Change-Id: I21f099a15dd3182d335a7891d99b9b1293e5c53e

googletest/include/gtest/internal/gtest-type-util.h

index f94cf614ade746bb16d9cbca197f83626871c0da..78da05316d6b0a1688a0992212527359a0e4e1ad 100644 (file)
@@ -71,7 +71,7 @@ inline std::string CanonicalizeForStdLibVersioning(std::string s) {
   // Strip redundant spaces in typename to match MSVC
   // For example, std::pair<int, bool> -> std::pair<int,bool>
   static const char to_search[] = ", ";
-  static const char replace_str[] = ",";
+  const char replace_char = ',';
   size_t pos = 0;
   while (true) {
     // Get the next occurrence from the current position
@@ -80,8 +80,8 @@ inline std::string CanonicalizeForStdLibVersioning(std::string s) {
       break;
     }
     // Replace this occurrence of substring
-    s.replace(pos, strlen(to_search), replace_str);
-    pos += strlen(replace_str);
+    s.replace(pos, strlen(to_search), 1, replace_char);
+    ++pos;
   }
   return s;
 }