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

            Bug ID: 81109
           Summary: [8 Regression]  new -Wclass-memaccess warning noisy
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: trippels at gcc dot gnu.org
                CC: msebor at gcc dot gnu.org
  Target Milestone: ---

The new -Wclass-memaccess warning (r249234) is noisy, e.g.:

 % cat deoptimizer-ppc.ii
class A {
  A();
};
struct B {
  struct C {
    A a;
  };
  C cache_[1];
  void Flush() { __builtin_memset(&cache_[0], 0, sizeof(cache_)); }
};

 % g++ -Wall -c deoptimizer-ppc.ii
deoptimizer-ppc.ii: In member function ‘void B::Flush()’:
deoptimizer-ppc.ii:9:64: warning: ‘void* __builtin_memset(void*, int, long
unsigned int)’ clearing an object of non-trivial type ‘struct B::C’; use
assignment instead [-Wclass-memaccess]
   void Flush() { __builtin_memset(&cache_[0], 0, sizeof(cache_)); }
                                                                ^
deoptimizer-ppc.ii:5:10: note: ‘struct B::C’ declared here
   struct C {
          ^

Build any non-trivial C++ project (like LLVM) and you will drown in warnings.

Not sure what to do, perhaps moving the warning to -Wextra?

Reply via email to