summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerek Mauro <dmauro@google.com>2024-07-10 16:14:40 (GMT)
committerCopybara-Service <copybara-worker@google.com>2024-07-10 16:15:21 (GMT)
commitb4aaf97d8f7eaffab79aa15e10a91b331b941fe2 (patch)
tree750d07299ace06cf4a2011a0a80becc5d40c0636
parent3ef16ef8b30f52a8f1ff677faa1730e76835aa40 (diff)
downloadgoogletest-b4aaf97d8f7eaffab79aa15e10a91b331b941fe2.zip
googletest-b4aaf97d8f7eaffab79aa15e10a91b331b941fe2.tar.gz
googletest-b4aaf97d8f7eaffab79aa15e10a91b331b941fe2.tar.bz2
Workaround GCC 12 -Wrestrict false-positive
Suggested workaround from https://github.com/Nekto89/googletest/commit/751760ad543f205e1d76797bcc5c7e2ca0c30cce Fixes #4570 PiperOrigin-RevId: 651044944 Change-Id: I21f099a15dd3182d335a7891d99b9b1293e5c53e
-rw-r--r--googletest/include/gtest/internal/gtest-type-util.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/googletest/include/gtest/internal/gtest-type-util.h b/googletest/include/gtest/internal/gtest-type-util.h
index f94cf61..78da053 100644
--- a/googletest/include/gtest/internal/gtest-type-util.h
+++ b/googletest/include/gtest/internal/gtest-type-util.h
@@ -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;
}