Details
-
Bug
-
Resolution: Out of scope
-
P1: Critical
-
None
-
6.7.0
-
None
-
CentOS 8.3.2011, gcc-toolset-9 (GCC 9.2.1 20191120)
Description
On some compilers QObject::inherits() in Qt 6.7.0 fails to return true when passing the classname of the current class.
A simplified example that reproduces this:
#include <QCoreApplication> #include <QDebug> #include <QObject> class MyObject : public QObject { Q_OBJECT public: MyObject() : QObject(nullptr) { qDebug() << inherits("MyObject") << inherits("QObject"); } }; int main(int argc, char **argv) { QCoreApplication app(argc, argv); MyObject mo; return 0; } #include "moc_qobjectinherits.cpp"
The above example was built and then executed on the following Linux x86_64 systems:
- Qt 6.6.0 + CentOS 8 + gcc-devtoolset-9 (gcc 9.2.1)
- Qt 6.7.0 + CentOS 8 + gcc-devtoolset-9 (gcc 9.2.1)
- Qt 6.7.0 + Ubuntu 22.04 (gcc 11.4.0)
Expected output is true true but with Qt 6.7.0 and gcc 9.2.1 it is false true.
A bit of debugging by modifying the generated MyObject::qt_metacast() moc code shows that the problematic compiler seems to "omit" the nul-terminator in the generated stringdata. When trying to print that out via qDebug("%s", qt_meta_stringdata_CLASSMyObjectENDCLASS.stringdata0) that gcc prints warning: ā%sā directive argument is not a nul-terminated string.
In comparison, gcc 11.4.0 on Ubuntu shows no warning for the same statement.
This is problematic for Squish (see SQUISH-17447) which requires this inherits check for finding objects via their classname (plus other property values).