Opened 5 years ago

Last modified 5 years ago

#1501 new defect

HM 16.20 fails to build with gcc8

Reported by: dbermond Owned by:
Priority: minor Milestone:
Component: HM Version: HM-16.14
Keywords: Cc: ksuehring, davidf, karlsharman, jct-vc@…

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
  • It builds fine with gcc 7.3.1.
  • It builds with gcc8 when removing -Werror from build/linux/common/makefile.base.

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:
OS: Arch Linux x86_64
Compiler: gcc 8.2.1
HM: 16.20 (svn revision 4994)

Attachments (1)

fix.patch (1.6 KB) - added by crosewarne 5 years ago.
Suggested fix for compilation issue under recent gcc

Download all attachments as: .zip

Change History (2)

Changed 5 years ago by crosewarne

Suggested fix for compilation issue under recent gcc

comment: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

  • Daniel Bermond(Reporter)
  • David Flynn(Subscriber)
  • jct-vc@…(Subscriber)
  • Karl Sharman(Subscriber)
  • karl.sharman@…(Always)
  • Karsten Suehring(Subscriber, Always)