diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2022-03-21 20:38:07 +0100 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2022-03-25 04:02:26 +0100 |
commit | 7d8150da4c20e1f9165e3c2642a183446220dd04 (patch) | |
tree | 410b918295f5d5f253e7cab4e838b61052873285 /src/corelib/kernel/qvariant.h | |
parent | 7dd454e1b94aa48ab6a6886782f83ad9b590f170 (diff) |
QVariant: disable building from arbitrary pointers
The QVariant(bool) is an extremely dangerous catch-all for all sorts of
things that may convert to bool, including arbitrary pointers. Delete
the corresponding constructor, in order to force users to use the
(correct) construction using fromValue, and/or to prevent bugs
altogether. This is technically speaking a SiC, but one of type A -- if
pointer to bool was intented, just do the conversion explicitly.
[ChangeLog][QtCore][QVariant] QVariant used to be constructible by raw
pointers through a conversion towards bool. This is now illegal. If such
a conversion is needed, users are advised to insert manual casts to
bool.
Change-Id: I1b1f81962259514e57d841246740e0f7050104e0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qvariant.h')
-rw-r--r-- | src/corelib/kernel/qvariant.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index ffc091ebf9..3481a5e347 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -228,6 +228,14 @@ class Q_CORE_EXPORT QVariant QVariant(const QModelIndex &modelIndex); QVariant(const QPersistentModelIndex &modelIndex); #endif +#if !defined(Q_CC_GHS) + // GHS has an ICE with this code; use the simplified version below + template <typename T, + std::enable_if_t<std::disjunction_v<std::is_pointer<T>, std::is_member_pointer<T>>, bool> = false> + QVariant(T) = delete; +#else + QVariant(const volatile void *) = delete; +#endif QVariant& operator=(const QVariant &other); inline QVariant(QVariant &&other) noexcept : d(other.d) |