Go to file
Giuseppe D'Angelo bb0a616260 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>
2020-04-15 15:20:45 +02:00
bin CMake: Provide script to configure and build one or more tests 2020-03-23 09:54:48 +01:00
cmake CMake: Fix $ORIGIN rpaths to work when passed on the command line 2020-04-15 11:43:02 +02:00
coin Coin: Fix incorrect target OS values used in instructions 2020-04-02 09:39:27 +02:00
config.tests CMake: Skip regeneration of manual compile test project 2020-04-09 11:26:46 +02:00
dist Add changes file for Qt 5.14.2 2020-03-17 06:16:25 +01:00
doc Merge remote-tracking branch 'origin/5.15' into dev 2020-04-08 20:11:39 +02:00
examples Port example over to QRegularExpression 2020-04-15 14:38:23 +02:00
lib
mkspecs Merge "Merge remote-tracking branch 'origin/5.15' into dev" 2020-04-11 15:04:45 +02:00
qmake Change qHash() to work with size_t instead of uint 2020-04-09 20:03:25 +02:00
src QObject: overhaul narrowing detection 2020-04-15 15:20:45 +02:00
tests QObject: overhaul narrowing detection 2020-04-15 15:20:45 +02:00
util CMake: pro2cmake expand variables for qt_add_resource() 2020-04-14 13:19:23 +02:00
.gitattributes
.gitignore QtNetwork: Delete bearer management 2020-04-05 16:41:08 +02:00
.qmake.conf Bump version 2020-02-02 13:41:14 +01:00
.tag
CMakeLists.txt CMake: Fix pkgconfig calls when cross-compiling 2020-03-26 12:46:16 +01:00
config_help.txt Merge remote-tracking branch 'origin/5.15' into dev 2020-02-26 18:39:21 +01:00
configure Merge remote-tracking branch 'origin/5.15' into dev 2020-04-08 20:11:39 +02:00
configure.bat Don't compile qmake in c++11 mode 2020-02-03 17:43:30 +01:00
configure.cmake CMake: Port the 'static' feature 2020-04-06 21:42:53 +02:00
configure.json CMake: Port the 'separate_debug_info' feature 2020-03-06 13:38:37 +01:00
configure.pri Android: Increase minimum API level to Android-23 / Android 6 2020-03-04 08:28:04 +01:00
dependencies.yaml Re-add dependencies.yaml now that qt5.git wip/qt6 builds fine 2019-09-18 13:19:31 +02:00
header.BSD Use placeholder for year in header.* files 2018-04-16 11:02:22 +00:00
header.COMM Use placeholder for year in header.* files 2018-04-16 11:02:22 +00:00
header.FDL Use placeholder for year in header.* files 2018-04-16 11:02:22 +00:00
header.GPL Use placeholder for year in header.* files 2018-04-16 11:02:22 +00:00
header.GPL-EXCEPT Use placeholder for year in header.* files 2018-04-16 11:02:22 +00:00
header.LGPL Use placeholder for year in header.* files 2018-04-16 11:02:22 +00:00
header.LGPL3 Use placeholder for year in header.* files 2018-04-16 11:02:22 +00:00
header.LGPL3-COMM Use placeholder for year in header.* files 2018-04-16 11:02:22 +00:00
header.LGPL-NOGPL2 Use placeholder for year in header.* files 2018-04-16 11:02:22 +00:00
header.LGPL-ONLY Use placeholder for year in header.* files 2018-04-16 11:02:22 +00:00
header.MIT qsimd: add support for new x86 CPU features 2018-05-05 06:20:07 +00:00
INSTALL INSTALL: Remove outdated reference to Windows CE 2019-02-13 13:01:57 +00:00
LICENSE.FDL
LICENSE.GPL2
LICENSE.GPL3
LICENSE.GPL3-EXCEPT
LICENSE.LGPL3
LICENSE.LGPLv3
LICENSE.QT-LICENSE-AGREEMENT Update enterprise license agreement v4.2.1 2019-12-18 13:07:19 +02:00
qtbase.pro
sync.profile Move QOpenGLWidget from QtOpenGL to its own module 2020-02-18 09:22:51 +01:00