https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82562
Bug ID: 82562 Summary: Incorrect warning: use copy-assignment or copy-initialization instead when copying build objects. Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: andi at mozilla dot com Target Milestone: --- Trying to build firefox with gcc8 I get this error, when building with treat -Werror: /usr/bin/g++-8 -std=gnu++11 -o RegExp.o -c -I/root/firefox-gcc-last/obj-x86_64-pc-linux-gnu/dist/system_wrappers -include /root/firefox-gcc-last/config/gcc_hidden.h -DDEBUG=1 -DENABLE_BINARYDATA -DENABLE_SIMD -DENABLE_WASM_THREAD_OPS -DWASM_HUGE_MEMORY -DJS_CACHEIR_SPEW -DENABLE_SHARED_ARRAY_BUFFER -DEXPORT_JS_API -DJS_HAS_CTYPES '-DDLL_PREFIX="lib"' '-DDLL_SUFFIX=".so"' -DFFI_BUILDING -DMOZ_HAS_MOZGLUE -I/root/firefox-gcc-last/js/src -I/root/firefox-gcc-last/obj-x86_64-pc-linux-gnu/js/src -I/root/firefox-gcc-last/obj-x86_64-pc-linux-gnu/js/src/ctypes/libffi/include -I/root/firefox-gcc-last/js/src/ctypes/libffi/src/x86 -I/root/firefox-gcc-last/obj-x86_64-pc-linux-gnu/dist/include -I/root/firefox-gcc-last/obj-x86_64-pc-linux-gnu/dist/include/nspr -fPIC -DMOZILLA_CLIENT -include /root/firefox-gcc-last/obj-x86_64-pc-linux-gnu/js/src/js-confdefs.h -MD -MP -MF .deps/RegExp.o.pp -Wall -Wc++11-compat -Wempty-body -Wignored-qualifiers -Woverloaded-virtual -Wpointer-arith -Wsign-compare -Wtype-limits -Wunreachable-code -Wwrite-strings -Wno-invalid-offsetof -Wc++14-compat -Wc++1z-compat -Wduplicated-cond -Wimplicit-fallthrough -Wno-error=maybe-uninitialized -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wformat -Wformat-overflow=2 -Wno-noexcept-type -fno-rtti -fno-exceptions -fno-math-errno -pthread -pipe -g -freorder-blocks -O3 -fno-omit-frame-pointer -Werror -Wno-shadow -Werror=format -fno-strict-aliasing /root/firefox-gcc-last/js/src/builtin/RegExp.cpp In file included from /root/firefox-gcc-last/js/src/builtin/RegExp.cpp:24:0: /root/firefox-gcc-last/js/src/vm/NativeObject-inl.h: In member function 'void js::NativeObject::copyDenseElements(uint32_t, const JS::Value*, uint32_t)': /root/firefox-gcc-last/js/src/vm/NativeObject-inl.h:155:67: error: 'void* memcpy(void*, const void*, size_t)' writing to an object of non-trivially copyable type 'class js::HeapSlot'; use copy-assignment or copy-initialization instead [-Werror=class-memaccess] memcpy(&elements_[dstStart], src, count * sizeof(HeapSlot)); ^ In file included from /root/firefox-gcc-last/js/src/jsatom.h:15:0, from /root/firefox-gcc-last/js/src/vm/Runtime.h:22, from /root/firefox-gcc-last/js/src/jscntxt.h:21, from /root/firefox-gcc-last/js/src/vm/RegExpObject.h:15, from /root/firefox-gcc-last/js/src/builtin/RegExp.h:10, from /root/firefox-gcc-last/js/src/builtin/RegExp.cpp:7: /root/firefox-gcc-last/js/src/gc/Barrier.h:655:7: note: 'class js::HeapSlot' declared here class HeapSlot : public WriteBarrieredBase<Value> ^~~~~~~~ In file included from /root/firefox-gcc-last/js/src/builtin/RegExp.cpp:24:0: /root/firefox-gcc-last/js/src/vm/NativeObject-inl.h: In member function 'void js::NativeObject::initDenseElements(const JS::Value*, uint32_t)': /root/firefox-gcc-last/js/src/vm/NativeObject-inl.h:184:52: error: 'void* memcpy(void*, const void*, size_t)' writing to an object of non-trivially copyable type 'class js::HeapSlot'; use copy-assignment or copy-initialization instead [-Werror=class-memaccess] memcpy(elements_, src, count * sizeof(HeapSlot)); I don't think that the warning is valid since what we try to do is copy in eleements_ the number of 'count' elements of type HeadSlop from src.