https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84850

            Bug ID: 84850
           Summary: new GCC version prints warning on memcpy call (no
                    nontrivial bases or members)
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: luhliari at redhat dot com
  Target Milestone: ---

Hello gcc-c++ team,

I'm trying to build squid with new gcc-c++, and I'm getting following error:

libtool: compile:  g++ -DHAVE_CONFIG_H -I../.. -I../../include -I../../lib
-I../../src -I../../include -I/usr/include/libxml2 -I/usr/include/libxml2 -Wall
-Wpointer-arith -Wwrite-strings -Wcomments -Wshadow -Woverloaded-virtual
-Werror -pipe -D_REENTRANT -O2 -g -pipe -Wall -Werror=format-security
-Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions
-fstack-protector-strong -grecord-gcc-switches
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic
-fasynchronous-unwind-tables -fstack-clash-protection -mcet -fcf-protection
-fPIC -c PoolChunked.cc  -fPIC -DPIC -o PoolChunked.o >/dev/null 2>&1
In file included from ../../src/anyp/PortCfg.h:14,
                 from ../../src/MasterXaction.h:13,
                 from ../../src/CommCalls.h:16,
                 from ../../src/comm.h:13,
                 from ../../src/CommRead.h:15,
                 from ../../src/Store.h:15,
                 from old_api.cc:26:
../../src/anyp/TrafficMode.h: In member function 'AnyP::TrafficMode&
AnyP::TrafficMode::operator=(const AnyP::TrafficMode&)':
../../src/anyp/TrafficMode.h:26:93: error: 'void* memcpy(void*, const void*,
size_t)' writing to an object of type 'class AnyP::TrafficMode' with no trivial
copy-assignment; use copy-assignment or copy-initialization instead
[-Werror=class-memaccess]
     TrafficMode &operator =(const TrafficMode &rhs) { memcpy(this, &rhs,
sizeof(TrafficMode)); return *this; }
                                                                               
             ^
In file included from ../../src/anyp/PortCfg.h:14,
                 from ../../src/MasterXaction.h:13,
                 from ../../src/CommCalls.h:16,
                 from ../../src/comm.h:13,
                 from ../../src/CommRead.h:15,
                 from ../../src/Store.h:15,
                 from old_api.cc:26:
../../src/anyp/TrafficMode.h:21:7: note: 'class AnyP::TrafficMode' declared
here
 class TrafficMode
       ^~~~~~~~~~~
In file included from ../../src/comm/Connection.h:18,
                 from ../../src/anyp/PortCfg.h:15,
                 from ../../src/MasterXaction.h:13,
                 from ../../src/CommCalls.h:16,
                 from ../../src/comm.h:13,
                 from ../../src/CommRead.h:15,
                 from ../../src/Store.h:15,
                 from old_api.cc:26:
../../src/eui/Eui64.h: In member function 'Eui::Eui64&
Eui::Eui64::operator=(const Eui::Eui64&)':
../../src/eui/Eui64.h:40:70: error: 'void* memcpy(void*, const void*, size_t)'
writing to an object of type 'class Eui::Eui64' with no trivial
copy-assignment; use copy-assignment or copy-initialization instead
[-Werror=class-memaccess]
     Eui64& operator= (const Eui64 &t) {memcpy(this, &t, sizeof(Eui64)); return
*this;}
                                                                      ^
../../src/eui/Eui64.h:34:7: note: 'class Eui::Eui64' declared here
 class Eui64
       ^~~~~
cc1plus: all warnings being treated as errors



I guess, in this case, warning should not be printed.

Reply via email to