-
Epic
-
Resolution: Unresolved
-
P2: Important
-
None
-
None
-
None
-
Clang 21 -Wcharacter-conversion
-
21
-
002aed143 (dev), 8279812b5 (6.10), dbcd1a538 (tqtc/lts-6.8)
Clang 21 added a new warning, -Wcharacter-conversions, which warns about all conversions (incl. comparisons) between char8_t, char16_t, char32_t. There's a hope they'll remove the warning for char16_t → char32_t again, because that currently wreaks havoc in the C++ world, or move this conversion to a different warning (level).
For now, we want to fix all these warnings in headers (which means it should be added to headerscheck), but in implementation files only fix those that are not about char16_t → char32_t.
Preferably, fixing involves more than slapping an explicit cast on the narrowing conversion. E.g. we have the following pattern quite widespread:
const char16_t *p = ~~~~; char32_t uc = *p++; if (QChar::isSurrogate(uc) && in-range) uc = QChar::surrogateToUcs4(uc, *p++); use(uc);
which prompts this warning (for both 16 → 32 and 32 → 16), but is readily fixed not as char16_t(uc), but as
const char16_t *p = ~~~~; const char16_t c = *p++; char32_t uc; // uninit'ed, to give the compiler the option of warning about it if (QChar::isSurrogate(c) && in-range) uc = QChar::surrogateToUcs4(c, *p++); else uc = c; use(uc);
Acceptance criteria:
- -Wcharacter-conversion is part of headerscheck
- all warnings from -Wcharacter-conversion that are not about char16_t → char32_t are fixed (see above for what "fix" means)
- rest is suppressed
For Gerrit Dashboard: QTBUG-141204 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
684662,7 | shiboken6: Silence clang warning occurring in Qt code | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
684734,2 | shiboken6: Silence clang warning occurring in Qt code | 6.10 | pyside/pyside-setup | Status: MERGED | +2 | 0 |
684767,2 | shiboken6: Silence clang warning occurring in Qt code | tqtc/lts-6.8 | pyside/tqtc-pyside-setup | Status: MERGED | +2 | 0 |