gcc/testsuite/g++.dg/warn/Wclass-memaccess-6.C
raw| 1 | /* PR c++/98835 - -Wclass-memaccess with class with ref-qualified |
| 2 | copy-assignment operator |
| 3 | { dg-do compile { target { c++11 } } } |
| 4 | { dg-options "-Wall" } */ |
| 5 | |
| 6 | struct Bad |
| 7 | { |
| 8 | Bad* operator& () { return this; } |
| 9 | Bad & operator=(Bad const &) & = default; |
| 10 | }; |
| 11 | |
| 12 | void test () |
| 13 | { |
| 14 | static_assert (__has_trivial_copy (Bad)); |
| 15 | |
| 16 | // T () = T (); // error |
| 17 | __builtin_memcpy (&Bad (), &Bad (), sizeof (Bad)); // { dg-warning "\\\[-Wclass-memaccess" } |
| 18 | } |