This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] tighten up -Wclass-memaccess for ctors/dtors (PR 84851)


A fix for 84851 - missing -Wclass-memaccess for a memcpy in a copy
ctor with a non-trivial member was implemented but disabled for GCC
8 but because it was late, with the expectation we would enable it
for GCC 9.  The attached removes the code that guards the full fix
to enable it.

Martin

PR c++/84851 - missing -Wclass-memaccess for a memcpy in a copy ctor with a non-trivial member

gcc/cp/ChangeLog:

	PR c++/84851
	* call.c (maybe_warn_class_memaccess): Tighten up.

gcc/testsuite/ChangeLog:

	PR c++/84851
	* g++.dg/Wclass-memaccess-4.C: Remove XFAIL.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 7aadd64..6a8ff6b 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -8535,15 +8535,6 @@ maybe_warn_class_memaccess (location_t loc, tree fndecl,
       bool special = same_type_ignoring_top_level_qualifiers_p (ctx, desttype);
       tree binfo = TYPE_BINFO (ctx);
 
-      /* FIXME: The following if statement is overly permissive (see
-	 bug 84851).  Remove it in GCC 9.  */
-      if (special
-	  && !BINFO_VTABLE (binfo)
-	  && !BINFO_N_BASE_BINFOS (binfo)
-	  && (DECL_CONSTRUCTOR_P (current_function_decl)
-	      || DECL_DESTRUCTOR_P (current_function_decl)))
-	return;
-
       if (special
 	  && !BINFO_VTABLE (binfo)
 	  && !first_non_trivial_field (desttype))
diff --git a/gcc/testsuite/g++.dg/Wclass-memaccess-4.C b/gcc/testsuite/g++.dg/Wclass-memaccess-4.C
index 8c33421..69b8c78 100644
--- a/gcc/testsuite/g++.dg/Wclass-memaccess-4.C
+++ b/gcc/testsuite/g++.dg/Wclass-memaccess-4.C
@@ -29,7 +29,7 @@ struct C
 
 C::C (const C &c)
 {
-  memcpy (this, &c, sizeof c);    // { dg-warning "\\\[-Wclass-memaccess]" "pr84851" { xfail *-*-*} }
+  memcpy (this, &c, sizeof c);    // { dg-warning "\\\[-Wclass-memaccess]" }
 }
 
 C& C::operator= (const C &c)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]