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

--- Comment #6 from Arsen Arsenović <arsen at gcc dot gnu.org> ---
so, indeed, this appears to fix the original testcase:

modified   gcc/gimple-ssa-warn-access.cc
@@ -1762,7 +1762,16 @@ new_delete_mismatch_p (tree new_decl, tree delete_decl)
   void *np = NULL, *dp = NULL;
   demangle_component *ndc = cplus_demangle_v3_components (new_str, 0, &np);
   demangle_component *ddc = cplus_demangle_v3_components (del_str, 0, &dp);
-  bool mismatch = ndc && ddc && new_delete_mismatch_p (*ndc, *ddc);
+
+  /* Sometimes, notably with coroutines, 'operator new' is templated, but in
+     those cases any possible template arguments cannot detract from it being
a
+     possible match for an operator delete, so we can ignore those template
+     arguments.  */
+  auto underlying_ndc = ndc;
+  if (ndc && ndc->type == DEMANGLE_COMPONENT_TEMPLATE)
+    underlying_ndc = ndc->u.s_binary.left;
+
+  bool mismatch = ndc && ddc && new_delete_mismatch_p (*underlying_ndc, *ddc);
   free (np);
   free (dp);
   return mismatch;

but, not entirely sure of correctness yet

Reply via email to