Skip to content

Commit fa8438a

Browse files
Abseil Teamcopybara-github
authored andcommitted
Use static_cast instead of ImplicitCast_ for character conversions
Clang has recently added "warnings when mixing different charN_t types" [1]. The rationale is that "charN_t represent code units of different UTF encodings. Therefore the values of 2 different charN_t objects do not represent the same characters." Note that the warning here may be legitimate - from #4762: "[...] This is incorrect for values that do not represent valid codepoints." For the time being, silence the warning by being more explicit about the conversion being intentional by using static_cast. Link: llvm/llvm-project#138708 [1] PiperOrigin-RevId: 760644157 Change-Id: I2e6cc1871975455cecac8731b2f93fd5beeaf0e1
1 parent 5719306 commit fa8438a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

googletest/include/gtest/gtest-printers.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,11 +521,15 @@ GTEST_API_ void PrintTo(wchar_t wc, ::std::ostream* os);
521521

522522
GTEST_API_ void PrintTo(char32_t c, ::std::ostream* os);
523523
inline void PrintTo(char16_t c, ::std::ostream* os) {
524-
PrintTo(ImplicitCast_<char32_t>(c), os);
524+
// TODO(b/418738869): Incorrect for values not representing valid codepoints.
525+
// Also see https://github.com/google/googletest/issues/4762.
526+
PrintTo(static_cast<char32_t>(c), os);
525527
}
526528
#ifdef __cpp_lib_char8_t
527529
inline void PrintTo(char8_t c, ::std::ostream* os) {
528-
PrintTo(ImplicitCast_<char32_t>(c), os);
530+
// TODO(b/418738869): Incorrect for values not representing valid codepoints.
531+
// Also see https://github.com/google/googletest/issues/4762.
532+
PrintTo(static_cast<char32_t>(c), os);
529533
}
530534
#endif
531535

0 commit comments

Comments
 (0)