D13900: Disable class-memaccess compiler warnings where not wanted

Friedrich W. H. Kossebau noreply at phabricator.kde.org
Fri Jul 6 15:03:27 BST 2018


kossebau added a comment.


  In D13900#287658 <https://phabricator.kde.org/D13900#287658>, @kfunk wrote:
  
  > What was the exact warning message to begin with? Can't this be fixed differently (i.e. without using the PP)?
  
  
  Find below a sample warning message per each entry.
  
  I have no deep understanding of the actual code, all seem more elaborated low-level memory magic to me, which though has existed for years without (known?) issues, so my motivation to try to rewrite it using proper (modern?) C++ expressions is rather low :) Perhaps worth a comment, but then I have no idea what to write besides "Dear clever code reader, please consider to rewrite this code using normal C++ class code" which though is IMHO an implicit with most/any given diagnostic pragmas ;) But feel challenged to be the clever code reader now :P I know it's just me to keep fingers from keyboard here.
  
  And the code from the affected headers is used quite often, which messes up the log build with the warnings quite a lot. Thus a bigger motivation to just silence those warnings down, given no-one might be able to do something soon, so it's useless log pain making one miss other more real issues.
  
    [ 30%] Building CXX object kdevplatform/language/CMakeFiles/KDevPlatformLanguage.dir/duchain/topducontext.cpp.o
    In file included from /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/language/util/basicsetrepository.h:21,
                     from /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/language/util/setrepository.h:17,
                     from /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/language/duchain/topducontext.h:24,
                     from /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/language/duchain/topducontext.cpp:20:
    /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/serialization/itemrepository.h: In instantiation of ‘void KDevelop::Bucket<Item, ItemRequest, markForReferenceCounting, fixedItemSize>::deleteItem(short unsigned int, unsigned int, Repository&) [with Repository = KDevelop::ItemRepository<Utils::SetNodeData, Utils::SetNodeDataRequest, false, false, 24>; Item = Utils::SetNodeData; ItemRequest = Utils::SetNodeDataRequest; bool markForReferenceCounting = false; unsigned int fixedItemSize = 24]’:
    /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/serialization/itemrepository.h:675:15:   required from ‘int KDevelop::Bucket<Item, ItemRequest, markForReferenceCounting, fixedItemSize>::finalCleanup(Repository&) [with Repository = KDevelop::ItemRepository<Utils::SetNodeData, Utils::SetNodeDataRequest, false, false, 24>; Item = Utils::SetNodeData; ItemRequest = Utils::SetNodeDataRequest; bool markForReferenceCounting = false; unsigned int fixedItemSize = 24]’
    /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/serialization/itemrepository.h:2070:17:   required from ‘int KDevelop::ItemRepository<Item, ItemRequest, markForReferenceCounting, threadSafe, fixedItemSize, targetBucketHashSize>::finalCleanup() [with Item = Utils::SetNodeData; ItemRequest = Utils::SetNodeDataRequest; bool markForReferenceCounting = false; bool threadSafe = false; unsigned int fixedItemSize = 24; unsigned int targetBucketHashSize = 1048576]’
    /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/serialization/itemrepository.h:2063:7:   required from here
    /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/serialization/itemrepository.h:564:13: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘struct Utils::SetNodeData’; use assignment or value-initialization instead [-Wclass-memaccess]
           memset(item, 0, size); //For debugging, so we notice the data is wrong
           ~~~~~~^~~~~~~~~~~~~~~
    In file included from /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/language/util/setrepository.h:17,
                     from /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/language/duchain/topducontext.h:24,
                     from /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/language/duchain/topducontext.cpp:20:
    /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/language/util/basicsetrepository.h:61:36: note: ‘struct Utils::SetNodeData’ declared here
     struct KDEVPLATFORMLANGUAGE_EXPORT SetNodeData {
                                        ^~~~~~~~~~~
  
    [ 30%] Building CXX object kdevplatform/language/CMakeFiles/KDevPlatformLanguage.dir/duchain/topducontextdynamicdata.cpp.o
    /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/language/duchain/topducontextdynamicdata.cpp: In function ‘void {anonymous}::saveDUChainItem(QVector<KDevelop::TopDUContextDynamicData::ArrayWithPosition>&, KDevelop::DUChainBase&, uint&, bool)’:
    /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/language/duchain/topducontextdynamicdata.cpp:93:40: warning: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of non-trivially copyable type ‘class KDevelop::DUChainBaseData’; use copy-assignment or copy-initialization instead [-Wclass-memaccess]
         memcpy(&target, item.d_func(), size);
                                            ^
    In file included from /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/language/duchain/problem.h:28,
                     from /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/language/duchain/topducontextdynamicdata.h:24,
                     from /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/language/duchain/topducontextdynamicdata.cpp:21:
    /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/language/duchain/duchainbase.h:59:35: note: ‘class KDevelop::DUChainBaseData’ declared here
     class KDEVPLATFORMLANGUAGE_EXPORT DUChainBaseData {
                                       ^~~~~~~~~~~~~~~
    /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/language/duchain/topducontextdynamicdata.cpp: In member function ‘KDevelop::TopDUContextDynamicData::ItemDataInfo KDevelop::TopDUContextDynamicData::writeDataInfo(const KDevelop::TopDUContextDynamicData::ItemDataInfo&, const KDevelop::DUChainBaseData*, uint&)’:
    /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/language/duchain/topducontextdynamicdata.cpp:768:28: warning: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of non-trivially copyable type ‘class KDevelop::DUChainBaseData’; use copy-assignment or copy-initialization instead [-Wclass-memaccess]
       memcpy(target, data, size);
                                ^
    In file included from /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/language/duchain/problem.h:28,
                     from /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/language/duchain/topducontextdynamicdata.h:24,
                     from /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/language/duchain/topducontextdynamicdata.cpp:21:
    /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/language/duchain/duchainbase.h:59:35: note: ‘class KDevelop::DUChainBaseData’ declared here
     class KDEVPLATFORMLANGUAGE_EXPORT DUChainBaseData {
                                       ^~~~~~~~~~~~~~~
  
  
  
    In file included from /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/language/duchain/codemodel.cpp:27:
    /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/util/embeddedfreetree.h: In instantiation of ‘bool KDevelop::EmbeddedTreeAddItem<Data, ItemHandler, increaseFraction, rebuildIfInsertionMoreExpensive>::insertSorted(const Data&, int, int, int, bool) [with Data = KDevelop::CodeModelItem; ItemHandler = KDevelop::CodeModelItemHandler; int increaseFraction = 5; int rebuildIfInsertionMoreExpensive = 20]’:
    /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/util/embeddedfreetree.h:505:22:   required from ‘bool KDevelop::EmbeddedTreeAddItem<Data, ItemHandler, increaseFraction, rebuildIfInsertionMoreExpensive>::apply(bool) [with Data = KDevelop::CodeModelItem; ItemHandler = KDevelop::CodeModelItemHandler; int increaseFraction = 5; int rebuildIfInsertionMoreExpensive = 20]’
    /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/util/embeddedfreetree.h:248:33:   required from ‘KDevelop::EmbeddedTreeAddItem<Data, ItemHandler, increaseFraction, rebuildIfInsertionMoreExpensive>::EmbeddedTreeAddItem(Data*, uint, int&, const Data&) [with Data = KDevelop::CodeModelItem; ItemHandler = KDevelop::CodeModelItemHandler; int increaseFraction = 5; int rebuildIfInsertionMoreExpensive = 20; uint = unsigned int]’
    /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/language/duchain/codemodel.cpp:201:140:   required from here
    /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/util/embeddedfreetree.h:700:28: warning: ‘void* memmove(void*, const void*, size_t)’ writing to an object of type ‘struct KDevelop::CodeModelItem’ with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Wclass-memaccess]
                         memmove(m_items+bound+1, m_items+bound, sizeof(Data)*(pos-bound));
                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/language/duchain/codemodel.cpp:19:
    /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/language/duchain/codemodel.h:35:10: note: ‘struct KDevelop::CodeModelItem’ declared here
       struct CodeModelItem
              ^~~~~~~~~~~~~
    In file included from /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/language/duchain/codemodel.cpp:27:
    /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/util/embeddedfreetree.h:709:28: warning: ‘void* memmove(void*, const void*, size_t)’ writing to an object of type ‘struct KDevelop::CodeModelItem’ with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Wclass-memaccess]
                         memmove(m_items+pos, m_items+pos+1, sizeof(Data)*(bound-pos-1));
                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/language/duchain/codemodel.cpp:19:
    /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/language/duchain/codemodel.h:35:10: note: ‘struct KDevelop::CodeModelItem’ declared here
       struct CodeModelItem
              ^~~~~~~~~~~~~
    In file included from /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/language/duchain/codemodel.cpp:27:
    /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/util/embeddedfreetree.h:712:22: warning: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘struct KDevelop::CodeModelItem’ with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Wclass-memaccess]
                    memcpy(m_items+target, backup, sizeof(Data));
                    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/language/duchain/codemodel.cpp:19:
    /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/kdevplatform/language/duchain/codemodel.h:35:10: note: ‘struct KDevelop::CodeModelItem’ declared here
       struct CodeModelItem
              ^~~~~~~~~~~~~
  
    /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/plugins/qmljs/3rdparty/qtcreator-libs/qmljs/parser/qmljsparser.cpp: In member function ‘void QmlJS::Parser::reallocateStack()’:
    /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/plugins/qmljs/3rdparty/qtcreator-libs/qmljs/parser/qmljsparser.cpp:76:104: warning: ‘void* realloc(void*, size_t)’ moving an object of non-trivially copyable type ‘class QStringRef’; use ‘new’ and ‘delete’ instead [-Wclass-memaccess]
         string_stack = reinterpret_cast<QStringRef*> (realloc(string_stack, stack_size * sizeof(QStringRef)));
                                                                                                            ^
    In file included from /usr/include/qt5/QtCore/qhashfunctions.h:44,
                     from /usr/include/qt5/QtCore/qlist.h:47,
                     from /usr/include/qt5/QtCore/qhash.h:46,
                     from /usr/include/qt5/QtCore/qshareddata.h:46,
                     from /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/plugins/qmljs/3rdparty/qtcreator-libs/qmljs/parser/qmljsmemorypool_p.h:48,
                     from /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/plugins/qmljs/3rdparty/qtcreator-libs/qmljs/parser/qmljsengine_p.h:47,
                     from /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/plugins/qmljs/3rdparty/qtcreator-libs/qmljs/parser/qmljsparser.cpp:31:
    /usr/include/qt5/QtCore/qstring.h:1418:21: note: ‘class QStringRef’ declared here
     class Q_CORE_EXPORT QStringRef {
                         ^~~~~~~~~~

REPOSITORY
  R32 KDevelop

REVISION DETAIL
  https://phabricator.kde.org/D13900

To: kossebau, #kdevelop
Cc: kfunk, kdevelop-devel, antismap, iodelay, vbspam, njensen, geetamc, Pilzschaf, akshaydeo, surgenight, arrowd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20180706/b5bef339/attachment-0001.html>


More information about the KDevelop-devel mailing list