Opened 6 years ago Last modified 5 years ago #1501 new defectHM 16.20 fails to build with gcc8
Description
HM 16.20 fails to build with gcc8, giving the following error: In file included from /storage/linux/src/hm/build/linux/lib/TLibCommon/../../../../source/Lib/TLibCommon/ContextModel3DBuffer.cpp:38: /storage/linux/src/hm/build/linux/lib/TLibCommon/../../../../source/Lib/TLibCommon/ContextModel3DBuffer.h: In member function ‘Void ContextModel3DBuffer::copyFrom(const ContextModel3DBuffer*)’: /storage/linux/src/hm/build/linux/lib/TLibCommon/../../../../source/Lib/TLibCommon/ContextModel3DBuffer.h:91:85: error: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of non-trivially copyable type ‘class ContextModel’; use copy-assignment or copy-initialization instead [-Werror=class-memaccess] ::memcpy( m_contextModel, src->m_contextModel, sizeof(ContextModel) * m_sizeXYZ ); ^ In file included from /storage/linux/src/hm/build/linux/lib/TLibCommon/../../../../source/Lib/TLibCommon/ContextModel3DBuffer.h:45, from /storage/linux/src/hm/build/linux/lib/TLibCommon/../../../../source/Lib/TLibCommon/ContextModel3DBuffer.cpp:38: /storage/linux/src/hm/build/linux/lib/TLibCommon/../../../../source/Lib/TLibCommon/ContextModel.h:57:7: note: ‘class ContextModel’ declared here class ContextModel ^~~~~~~~~~~~ cc1plus: all warnings being treated as errors make[1]: *** [../../common/makefile.base:241: objects/ContextModel3DBuffer.r.o] Error 1 make[1]: Leaving directory '/storage/linux/src/hm/build/linux/lib/TLibCommon' make: *** [makefile:49: release] Error 2
Steps used to build: $ svn checkout -r 4994 https://hevc.hhi.fraunhofer.de/svn/svn_HEVCSoftware/trunk/ hm $ cd hm/build/linux $ make -j1 -f makefile release release_highbitdepth
System Information: Attachments (1)Change History (2)Changed 5 years ago by crosewarnecomment:1 Changed 5 years ago by crosewarne
I believe this is due to recent gcc versions prohibiting using memcpy to copy an instance of a class unless the class is 'trivially copyable'. In this case the presence of the constructor (and even the destructor also seemed relevant somehow) causes the compiler to not consider the class trivially copyable.
The attached patch uses 'default member initializers' to initialize instead of the constructor. This enables compilation under gcc-9.1.0. However, I understand default member initializers are a feature of C++11. Under gcc-4.8.5 the code compiled with this patch and a test case produced identical result, but I am unsure if the patch is suitable for all older compilers we should support. Note: See
TracTickets for help on using
tickets. | This list contains all users that will be notified about changes made to this ticket. These roles will be notified: Reporter, Owner, Subscriber, Participant
|
Suggested fix for compilation issue under recent gcc