diff options
| author | Marc Mutz <marc.mutz@qt.io> | 2025-10-16 10:33:54 +0200 |
|---|---|---|
| committer | Marc Mutz <marc.mutz@qt.io> | 2025-10-19 16:24:47 +0000 |
| commit | bda2c016f52318a52a0a6cb9fe0e6d0f21c9ddbe (patch) | |
| tree | 2e99bebf3ab697aff5794da29735d585b0b5ea2b /src/corelib/text/qstring.cpp | |
| parent | a4d5432fcc182535ce2014695516b482a4a76777 (diff) | |
QChar: avoid char{32→16}_t narrowing in (de)composeHelper()
The old code used a char32_t to temporarily store a UTF-16 code
point. Upon finding it to be a surrogate, it then had to narrow it
back to char16_t for the call to QChar::surrogateToUcs4(). It also
invoked QChar(uint), a ctor which should have never existed to begin
with.
Rewrite the functions to keep the UTF-16 code point in a char16_t
variable until it's inspected to be either safe for promotion to
char32_t or else has been decoded (or decoding failed). This requires
to write 'uc = c' twice instead of once, but allows us to add a
comment on the failed-decoding path to guide the reader of the code,
improving readability.
Specifically declare `uc` as uninit'ed to provoke compiler warnings
when code is changed to forget to assign to `uc`.
Found by Clang 21's -Wcharacter-conversion.
Amends the start of the public history.
Pick-to: 6.10 6.8 6.5
Change-Id: I8d43b4c0e0b3852ddf730f349886bd6943b94f17
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Diffstat (limited to 'src/corelib/text/qstring.cpp')
0 files changed, 0 insertions, 0 deletions
