Skip to content

Commit

Permalink
Workaround GCC 12 -Wrestrict false-positive
Browse files Browse the repository at this point in the history
Suggested workaround from Nekto89@751760a

Fixes #4570

PiperOrigin-RevId: 651044944
Change-Id: I21f099a15dd3182d335a7891d99b9b1293e5c53e
  • Loading branch information
derekmauro authored and copybara-github committed Jul 10, 2024
1 parent 3ef16ef commit b4aaf97
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions googletest/include/gtest/internal/gtest-type-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
Expand Down

0 comments on commit b4aaf97

Please sign in to comment.