Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
4.7.1
-
None
-
Solaris
-
5e3c4b6a82df640c15778af72384c6b27f8860b7
Description
The current implementation of qobject_cast qobject.h makes the CC compiler raise severe warnings:
Warning, nullref: Initializing const myClass& to a NULL value.
This is because of the 1rst statement reinterpret_cast<T>(0) wich is used to call the not static method qt_check_for_QOBJECT_macro:
template <class T>
inline T qobject_cast(QObject *object)
{
#if !defined(QT_NO_MEMBER_TEMPLATES) && !defined(QT_NO_QOBJECT_CHECK)
reinterpret_cast<T>(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast<T>(object));
#endif
return static_cast<T>(reinterpret_cast<T>(0)->staticMetaObject.cast(object));
}
The quick and temporary solution is to setup the variable QT_NO_QOBJECT_CHECK, but the longer term one might probably to have:
template <class T>
inline T qobject_cast(QObject *object)
{
#if !defined(QT_NO_MEMBER_TEMPLATES) && !defined(QT_NO_QOBJECT_CHECK)
reinterpret_cast<T>( object)->qt_check_for_QOBJECT_macro(*reinterpret_cast<T>(object));
#endif
return static_cast<T>(reinterpret_cast<T>( object)->staticMetaObject.cast(object));
}