Verify a warning for a class with a ref-qualified assignment (PR c++/98835).
gcc/testsuite/ChangeLog: PR c++/98835 * g++.dg/Wclass-memaccess-6.C: New test.
This commit is contained in:
parent
7e534fb7d8
commit
c2f8e378d6
1 changed files with 18 additions and 0 deletions
18
gcc/testsuite/g++.dg/Wclass-memaccess-6.C
Normal file
18
gcc/testsuite/g++.dg/Wclass-memaccess-6.C
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* PR c++/98835 - -Wclass-memaccess with class with ref-qualified
|
||||
copy-assignment operator
|
||||
{ dg-do compile { target { c++11 } } }
|
||||
{ dg-options "-Wall" } */
|
||||
|
||||
struct Bad
|
||||
{
|
||||
Bad* operator& () { return this; }
|
||||
Bad & operator=(Bad const &) & = default;
|
||||
};
|
||||
|
||||
void test ()
|
||||
{
|
||||
static_assert (__has_trivial_copy (Bad));
|
||||
|
||||
// T () = T (); // error
|
||||
__builtin_memcpy (&Bad (), &Bad (), sizeof (Bad)); // { dg-warning "\\\[-Wclass-memaccess" }
|
||||
}
|
Loading…
Add table
Reference in a new issue