[Development] Qt 5: Warning using QImage as QtConcurrent::mapped return type

Thiago Macieira thiago.macieira at intel.com
Mon Oct 1 01:13:14 CEST 2012


On domingo, 30 de setembro de 2012 18.50.49, Olivier Goffart wrote:
> > In file included from /Qt/5.0/qtbase/include/QtCore/qvector.h:1:
> > /Qt/5.0/qtbase/include/QtCore/../../src/corelib/tools/qvector.h:459:56:
> > warning: source of this 'memcpy' call is a pointer to dynamic class
> > 'QImage'; vtable pointer will be copied [-Wdynamic-class-memaccess]
> >
> > 
> >                      ::memcpy(static_cast<void *>(dst), srcBegin,
> > 
> >
> > (srcEnd - srcBegin) * sizeof(T));
> >
> >                      ~~~~~~~~                           ^
> > 
> >
> > It seems that Qt thinks QImage is a POD type?
> 
> Because QImage is registered as Q_MOVABLE_TYPE. 
> (It is the case since Q_DECLARE_SHARED does that)
> 
> It shuld be safe in that case, because virtual table pointer should be 
> movable, and we know that we have arrays of QImage and not the derived type.
> 
> But this warning may be annoying. Maybe should we work around it

We have.

commit 60829b4a5692ebdd68b12830d7c722ccd31921ad
Author: Kent Hansen <kent.hansen at nokia.com>
Date:   Tue Jun 19 10:46:05 2012 +0200

    Silence clang warning in QVector::reallocData()
    
    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*)

We followed clang's recommendation to static_cast to void*. Clang can't 
complain that we're doing exactly what it suggested we do.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
     Intel Sweden AB - Registration Number: 556189-6027
     Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20120930/272fca21/attachment.sig>


More information about the Development mailing list