PR c++/84850 - -Wclass-memaccess on a memcpy in a copy assignment operator with no...
[official-gcc.git] / gcc / testsuite / g++.dg / Wclass-memaccess-4.C
blob8c334219099ecb3948a17ea470d2cd29b47cd014
1 /* PR c++/84850 - missing -Wclass-memaccess for a memcpy in a copy ctor
2    with a non-trivial member
3    { dg-do compile }
4    { dg-options "-Wclass-memaccess -ftrack-macro-expansion=0" } */
6 typedef __SIZE_TYPE__ size_t;
8 extern "C" void* memcpy (void*, const void*, size_t);
10 struct A
12   const int &r;
14   A ();
16   A (const A&);
18   virtual ~A ();
21 struct C
23   A a;
25   C (const C&);
27   C& operator= (const C&);
30 C::C (const C &c)
32   memcpy (this, &c, sizeof c);    // { dg-warning "\\\[-Wclass-memaccess]" "pr84851" { xfail *-*-*} }
35 C& C::operator= (const C &c)
37   memcpy (this, &c, sizeof c);    // { dg-warning "\\\[-Wclass-memaccess]" }
38   return *this;