From 60829b4a5692ebdd68b12830d7c722ccd31921ad Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Tue, 19 Jun 2012 10:46:05 +0200 Subject: Silence clang warning in QVector::reallocData() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit qvector.h:459:30: warning: destination for this 'memcpy' call is a pointer to dynamic class 'QImage'; vtable pointer will be overwritten [-Wdynamic-class-memaccess] ::memcpy(dst, srcBegin, (srcEnd - srcBegin) * sizeof(T)); ~~~~~~~~ ^ qvector.h:459:30: note: explicitly cast the pointer to silence this warning ::memcpy(dst, srcBegin, (srcEnd - srcBegin) * sizeof(T)); ^ (void*) QImage inherits from QPaintDevice, which has virtual functions. qimage.h declares QImage as a movable type, so QTypeInfo::isStatic is false. Hence, the memcpy codepath will be reached when the vector is not shared. We should trust that people declaring such type traits know what they're doing, so silence the warning. Change-Id: If36582f57a398fc237fb4bd4f72938fb09667118 Reviewed-by: Jędrzej Nowacki Reviewed-by: Thiago Macieira --- src/corelib/tools/qvector.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib/tools/qvector.h') diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index b75c2975b6..f3ef9b97c3 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -456,7 +456,7 @@ void QVector::reallocData(const int asize, const int aalloc, QArrayData::Allo new (dst++) T(*srcBegin++); } } else { - ::memcpy(dst, srcBegin, (srcEnd - srcBegin) * sizeof(T)); + ::memcpy(static_cast(dst), srcBegin, (srcEnd - srcBegin) * sizeof(T)); dst += srcEnd - srcBegin; // destruct unused / not moved data -- cgit v1.2.3