diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-11-16 03:08:47 +0100 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-11-20 03:34:37 +0100 |
commit | 915be6606ead25f4fbbbcb2687b33cf22a955177 (patch) | |
tree | ef543afc8455ea457542288cb63c2f8601bc9469 /src | |
parent | 06f58a909bcdcd08d125f5decd1fba894c285765 (diff) |
QChar: assert on illegal construction
If the input is out of range for the respective input type,
then fire an assert. Remove a redudant bitwise-and.
The constructors from char have been left alone: we are
documenting that QChar(char) constructs from Latin1 (!), not
ASCII/UTF-8, so all values are valid.
Change-Id: I55e261015d5efa0699c78c25e454f09bb17a913f
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/text/qchar.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/text/qchar.h b/src/corelib/text/qchar.h index 04aeed8678..32ecfa0e48 100644 --- a/src/corelib/text/qchar.h +++ b/src/corelib/text/qchar.h @@ -111,8 +111,8 @@ public: constexpr Q_IMPLICIT QChar(ushort rc) noexcept : ucs(rc) {} constexpr QCHAR_MAYBE_IMPLICIT QChar(uchar c, uchar r) noexcept : ucs(char16_t((r << 8) | c)) {} constexpr Q_IMPLICIT QChar(short rc) noexcept : ucs(char16_t(rc)) {} - constexpr QCHAR_MAYBE_IMPLICIT QChar(uint rc) noexcept : ucs(char16_t(rc & 0xffff)) {} - constexpr QCHAR_MAYBE_IMPLICIT QChar(int rc) noexcept : ucs(char16_t(rc & 0xffff)) {} + constexpr QCHAR_MAYBE_IMPLICIT QChar(uint rc) noexcept : ucs((Q_ASSERT(rc <= 0xffff), char16_t(rc))) {} + constexpr QCHAR_MAYBE_IMPLICIT QChar(int rc) noexcept : QChar(uint(rc)) {} constexpr Q_IMPLICIT QChar(SpecialCharacter s) noexcept : ucs(char16_t(s)) {} constexpr Q_IMPLICIT QChar(QLatin1Char ch) noexcept : ucs(ch.unicode()) {} constexpr Q_IMPLICIT QChar(char16_t ch) noexcept : ucs(ch) {} |