From 49057a1eab3d226d504db0e12e65e27fa9b42c2d Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 15 Jan 2015 14:58:06 +0100 Subject: QVariant: attempt to work around an ICE on linux-arm-gnueabi-g++ (Ubuntu 11.10) with constexpr QSizePolicy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is the error: src/corelib/kernel/qvariant_p.h: In constructor ‘QVariantPrivateSharedEx::QVariantPrivateSharedEx() [with T = QSizePolicy]’: src/corelib/kernel/qvariant_p.h:107:61: internal compiler error: in gimplify_init_ctor_eval, at gimplify.c:3560 There are two things fishy in this file: 1. Use of the unnamed namespace in a file that gets included in different libraries. While not technically undefined behavior, it may become so when used in the implementation, which it is. 2. Missing explicit initialization of a member of QVariantPrivateSharedEx. This is just a wild guess, because the ICE happens in that line. That class itself is quite smelly, because the address of an object is taken before the lifetime of the object begins. A fix would be to store the object in a wrapper class from which QVPSEx inherits _first_, but then a cast from QVPSEx to QVariant::PrivateShared would require pointer adjustments, and I didn't look through all the code to determine whether that would be an issue. Having been bitten by this sometime ago: https://marcmutz.wordpress.com/private-practice/private-practice-taming-templates/#edit-20111128 I opted to do these easy changes first to see whether they already fix the ICE. Change-Id: Ic15fd928b3dff2318c425c915b2dab5e54254d71 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qvariant_p.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/corelib/kernel/qvariant_p.h b/src/corelib/kernel/qvariant_p.h index 9b9e266f8e..9e4f468872 100644 --- a/src/corelib/kernel/qvariant_p.h +++ b/src/corelib/kernel/qvariant_p.h @@ -54,7 +54,6 @@ QT_BEGIN_NAMESPACE -namespace { template struct QVariantIntegrator { @@ -64,7 +63,6 @@ struct QVariantIntegrator Q_STATIC_ASSERT(QVariantIntegrator::CanUseInternalSpace); Q_STATIC_ASSERT(QVariantIntegrator::CanUseInternalSpace); Q_STATIC_ASSERT(QVariantIntegrator::CanUseInternalSpace); -} // namespace #ifdef Q_CC_SUN // Sun CC picks the wrong overload, so introduce awful hack @@ -104,7 +102,7 @@ inline T *v_cast(QVariant::Private *d, T * = 0) template class QVariantPrivateSharedEx : public QVariant::PrivateShared { public: - QVariantPrivateSharedEx() : QVariant::PrivateShared(&m_t) { } + QVariantPrivateSharedEx() : QVariant::PrivateShared(&m_t), m_t() { } QVariantPrivateSharedEx(const T&t) : QVariant::PrivateShared(&m_t), m_t(t) { } private: -- cgit v1.2.3