Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.6.0 Beta4
-
None
Description
The QAccessible::Role enum is declared as
enum Role {
NoRole = 0x00000000,
[...]
UserRole = 0x0000ffff
};
QAccessible::UserRole is documented as
The first value to be used for user defined roles.
which, as far as I understand, means that we should be able to do something like
static constexpr QAccessible::Role ValueRole = static_cast<QAccessible::Role>(QAccessible::UserRole + 1);
to define a custom role. But this doesn't compile with Clang 16:
error: integer value 65536 is outside the valid range of values [0, 65535] for this enumeration type [-Wenum-constexpr-conversion] static constexpr QAccessible::Role ValueRole = static_cast<QAccessible::Role> (QAccessible::UserRole + 1); ^
Clang is correct because this cast is undefined behavior.
Minimal example:
#include <QAccessible> static constexpr QAccessible::Role ValueRole = static_cast<QAccessible::Role>(QAccessible::UserRole + 1);
I have compiled this with
clang++-16.0 -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtGui -std=gnu++20 main.cpp
A possible fix would be to fix the type of the enum, e.g.
enum Role : int { NoRole = 0x00000000, [...] UserRole = 0x0000ffff };
Attachments
Gerrit Reviews
For Gerrit Dashboard: QTBUG-117517 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
527263,1 | Fix QAccessible::UserRole with clang > 16 | dev | qt/qtbase | Status: NEW | 0 | 0 |