Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.5.0
-
None
-
Archlinux using gcc 5.1.0
-
Ibd260de88c174c1aa3833a56b153b8b74d337338
Description
Since qt5.5 the following code will no longer compile:
#include <QDebug> //Needed to cause the error! #include <QDataStream> class TestClass { public: int a; QString b; //QDataStream operators ommited, for readability }; template QDataStream& operator<< <TestClass>(QDataStream&, QList<TestClass> const&); template QDataStream& operator>> <TestClass>(QDataStream&, QList<TestClass>&);
Error:
/usr/include/qt/QtCore/qflags.h:88: error: invalid application of 'sizeof' to incomplete type 'QStaticAssertFailure<false>'
Q_STATIC_ASSERT_X((sizeof(Enum) <= sizeof(int)),
^
/usr/include/qt/QtCore/qtypetraits.h:-1: In instantiation of 'struct QtPrivate::is_unsigned<TestClass>':
/usr/include/qt/QtCore/qflags.h:103: required from 'class QFlags<TestClass>'
/usr/include/qt/QtCore/qmetatype.h:1386: required from 'struct QtPrivate::IsQEnumHelper<QFlags<TestClass> >'
/usr/include/qt/QtCore/qdebug.h:290: required by substitution of 'template<class T> typename QtPrivate::QEnableIf<((! QtPrivate::IsQEnumHelper<T>::Value) && (! QtPrivate::IsQEnumHelper<QFlags<T> >::Value)), QDebug>::Type operator<<(QDebug, const QFlags<T>&) [with T = TestClass]'
The reason for this is a unsafe template in qdebug.h:290
I suggest adding a safe QtPrivate::IsQFlagsHelper<T> instead of using QtPrivate::IsQEnumHelper<QFlags<T> >.
That new IsQFlagsHelper would first have to check if T is an integral type, before instantiating QFlags<T>.