Bug 1770107 - Disambiguate char16_t* operator== overloads in MinGW build for C++23. r=xpcom-reviewers,nika

C++23 is stricer about matching operator== overloads than C++17 and char16ptr_t's implicit constructor causes some overload confusion. We can disambigutate the operator== overloads by adding typed local variables without needing type casts.

xpcom/io/nsLinebreakConverter.cpp:447:17: error: use of overloaded operator '!=' is ambiguous (with operand types 'nsTSubstring<char16_t>::iterator' (aka 'char16_t *') and 'typename raw_type<char16_t, int>::type' (aka 'char16ptr_t'))
 if (stringBuf != aIoString.get()) {
     ~~~~~~~~~ ^  ~~~~~~~~~~~~~~~
mozilla/Char16.h:95:8: note: candidate function (with reversed parameter order)
 bool operator==(const char16ptr_t& aOther) const {
      ^
xpcom/io/nsLinebreakConverter.cpp:447:17: note: built-in candidate operator!=(const char16_t *, const char16_t *)
 if (stringBuf != aIoString.get()) {
               ^
xpcom/io/nsLinebreakConverter.cpp:447:17: note: built-in candidate operator!=(const volatile char16_t *, const volatile char16_t *)
xpcom/io/nsLinebreakConverter.cpp:447:17: note: built-in candidate operator!=(const void *, const void *)
xpcom/io/nsLinebreakConverter.cpp:447:17: note: built-in candidate operator!=(const volatile void *, const volatile void *)

Differential Revision: https://phabricator.services.mozilla.com/D146772
This commit is contained in:
Chris Peterson 2022-05-20 06:06:19 +00:00
Родитель 6ef19ca2a9
Коммит c686ea7b47
1 изменённых файлов: 3 добавлений и 2 удалений

Просмотреть файл

@ -431,7 +431,7 @@ nsresult nsLinebreakConverter::ConvertStringLineBreaks(
// remember the old buffer in case
// we blow it away later
auto stringBuf = aIoString.BeginWriting(mozilla::fallible);
char16_t* stringBuf = aIoString.BeginWriting(mozilla::fallible);
if (!stringBuf) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -444,7 +444,8 @@ nsresult nsLinebreakConverter::ConvertStringLineBreaks(
return rv;
}
if (stringBuf != aIoString.get()) {
const char16_t* currentBuf = aIoString.get();
if (currentBuf != stringBuf) {
aIoString.Adopt(stringBuf, newLen - 1);
}