diff options
| author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-03-24 08:47:00 +0100 |
|---|---|---|
| committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-04-15 15:20:45 +0200 |
| commit | bb0a6162608fe932f8534bbe65594c6bf894867a (patch) | |
| tree | 2f5569bf59ed7180f7fc6e558c9292e782e7937a /src/opengl/qopenglvertexarrayobject.cpp | |
| parent | 76e54a2e151a7d31e18feb84cc79451724ab7c6f (diff) | |
QObject: overhaul narrowing detection
Use P0608's trick to detect convertibility without narrowing;
and now that we can depend on C++17, use its features.
First, this moves the burden of detecting a narrowing conversion on
the compiler, rather than us maintaining a complicated series
of checks. Of course, this exposes
* bugs in compilers (e.g. GCC < 9 thinks that float->bool is not
narrowing;
* behavior still not (widely) implemented (pointer to bool
conversions are narrowing, P1957);
* interesting compiler choices, e.g. GCC 9 thinks that unscoped
enumerations are non-narrowing convertible to a datatype big
enum to contain all the _enumerators_, even if the underlying
type of the enum (and/or its sizeof()) is wider than the target
datatype.
Second, it allows to detect conversions that have a narrowing
conversion as an intermediate step. Given a type like
struct Bad { operator double() const; };
then an object of type Bad is implictly convertible to a type
like int via a narrowing conversion. Therefore, a connection
is possible between a signal carrying a Bad and a slot accepting
an int. We can now detect and block this.
Tests regarding scoped enumerations have been dropped,
for the simple reason that a scoped enumeration is not
implictly convertible to an integral type, so we don't have
that detection (it would constantly fail). Scoped enumerations
do not take part in narrowing conversions anyhow, cf. [dcl.init.list].
[ChangeLog][QtCore][QObject] The detection of narrowing conversions
when calling QObject::connect() when
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT now takes also
into account user-defined implicit conversions that undergo
through a narrowing conversion.
Change-Id: Ie09d59203fe6283378b36dfbc54de1d58098ef51
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/opengl/qopenglvertexarrayobject.cpp')
0 files changed, 0 insertions, 0 deletions
