aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2014-01-03 20:59:43 -0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-10 00:41:28 +0100
commitd580411cab0d0a91c73e111ac2c0c6c8f77118fa (patch)
tree8ee21c721a11862e5c9ed82a71d5cb5d7097380d /src
parentf5c6987ef8f09873dcfc47b5d4dbd532da660b2b (diff)
Fix bad cast of virtual class to base class via reinterpret_cast
Clang 3.4 found it: qv4managed_p.h:202:9: error: 'reinterpret_cast' to class 'QQmlDelegateModelGroupChangeArray *' from its base at non-zero offset 'QV4::Managed *' behaves differently from 'static_cast' [-Werror,--Wreinterpret-base-class] QV4::Managed and QV4::Object are non-virtual classes (they have no virtual table). I'm not sure if they are (C++11) standard layout, but they seem to fit the bill. However, QQmlDelegateModelGroupChangeArray has virtual functions, so the QV4::Managed sub-object in that class does not start at offset zero. That means reinterpret_cast'ing the base to the derived class is *wrong*, even if we're just calling a static function. In any case, we're static_cast'ing in the next line anyway, so this can't hurt. Change-Id: Icc796f7ecf8f41f859ea5fc877f5db5c87799964 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/qml/jsruntime/qv4managed_p.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h
index 63972688a7..e10409f397 100644
--- a/src/qml/jsruntime/qv4managed_p.h
+++ b/src/qml/jsruntime/qv4managed_p.h
@@ -199,7 +199,7 @@ public:
if (!this || !internalClass)
return 0;
#if !defined(QT_NO_QOBJECT_CHECK)
- reinterpret_cast<T *>(this)->qt_check_for_QMANAGED_macro(*reinterpret_cast<T *>(this));
+ static_cast<T *>(this)->qt_check_for_QMANAGED_macro(*static_cast<T *>(this));
#endif
return internalClass->vtable == &T::static_vtbl ? static_cast<T *>(this) : 0;
}