[Development] Qt/5.0.0, clang/3.2, C++11 and qRegisterMetaType, Q_BASIC_ATOMIC_INITIALIZER

Jan Kundrát jkt at flaska.net
Thu Apr 11 19:53:04 CEST 2013


Hi, I'm trying to port an application to Qt5. This is on a Linux system with clang 3.2 and Qt 5.0.0. The application requires C++11, but this particular file builds just fine when I remove -std=c++11 from the command line options. Build also succeeds with Gentoo's GCC 4.6.3 invoked with -std=c++0x (there's no -std=c++11 in that old GCC).

It seems that clang isn't terribly happy with the initialization of QBasicAtomicInt expanded from qRegisterMetaType:

/usr/bin/clang++   -DQT_CORE_LIB -DQT_DECLARATIVE_LIB -DQT_GUI_LIB -DQT_SCRIPT_LIB -DQT_WIDGETS_LIB -fPIE -Wall -Wextra -Wnon-virtual-dtor -Wold-style-cast -Woverloaded-virtual -std=c++11 -g -I/opt/qt5/include -I/opt/qt5/include/QtWidgets -I/opt/qt5/include/QtGui -I/opt/qt5/include/QtCore -I/opt/qt5/mkspecs/linux-g++-64 -I/opt/qt5/include/QtDeclarative -I/opt/qt5/include/QtScript -I/home/jkt/work/cesnet/opticke-site/editor -I/home/jkt/work/cesnet/opticke-site/editor/build/qt5-clang-debug/generated    -o CMakeFiles/Types.dir/Types/DeviceTypeEngine.cpp.o -c /home/jkt/work/cesnet/opticke-site/editor/Types/DeviceTypeEngine.cpp
In file included from /home/jkt/work/cesnet/opticke-site/editor/Types/DeviceTypeEngine.cpp:1:
In file included from /home/jkt/work/cesnet/opticke-site/editor/Types/DeviceTypeEngine.h:4:
In file included from /opt/qt5/include/QtDeclarative/QDeclarativeEngine:1:
In file included from /opt/qt5/include/QtDeclarative/qdeclarativeengine.h:46:
In file included from /opt/qt5/include/QtCore/qobject.h:55:
/opt/qt5/include/QtCore/qmetatype.h:669:32: error: copying variable of type 'QBasicAtomicInt' (aka 'QBasicAtomicInteger<int>') invokes deleted constructor
        static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0);
                               ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/qt5/include/QtCore/qmetatype.h:534:82: note: in instantiation of member function 'QMetaTypeIdQObject<QMLDeviceType *, true>::qt_metatype_id' requested here
    static inline Q_DECL_CONSTEXPR int qt_metatype_id() { return QMetaTypeId<T>::qt_metatype_id(); }
                                                                                 ^
/opt/qt5/include/QtCore/qmetatype.h:618:12: note: in instantiation of function template specialization 'qRegisterNormalizedMetaType<QMLDeviceType *>' requested here
    return qRegisterNormalizedMetaType<T>(normalizedTypeName, dummy, defined);
           ^
/opt/qt5/include/QtDeclarative/qdeclarative.h:170:9: note: in instantiation of function template specialization 'qRegisterMetaType<QMLDeviceType *>' requested here
        qRegisterMetaType<T *>(pointerName.constData()),
        ^
/home/jkt/work/cesnet/opticke-site/editor/Types/DeviceTypeEngine.cpp:12:5: note: in instantiation of function template specialization 'qmlRegisterType<QMLDeviceType>' requested here
    qmlRegisterType<QMLDeviceType>("org.czechlight.ndl.Types", 1, 0, "DeviceType");
    ^
/opt/qt5/include/QtCore/qbasicatomic.h:198:5: note: function has been explicitly marked deleted here
    QBasicAtomicInteger(const QBasicAtomicInteger &) = delete;


Is that a bug in clang, or in Qt?

With kind regards,
Jan

-- 
Trojitá, a fast Qt IMAP e-mail client -- http://trojita.flaska.net/



More information about the Development mailing list