We are diagnosing
operator delete (this_3(D));
A::f (this_3(D));
*this_3(D) ={v} CLOBBER;
where the CLOBBER appears at the end of the DTOR for C++11 and later.
The following avoids this by simply never diagnosing clobbers as
use-after-free.
* gimple-ssa-warn-access.cc (pass_waccess::check_pointer_uses):
Do not diagnose clobbers.
* g++.dg/warn/Wuse-after-free3.C: Remove expected duplicate
diagnostic.
if (use_stmt == stmt || is_gimple_debug (use_stmt))
continue;
+ /* A clobber isn't a use. */
+ if (gimple_clobber_p (use_stmt))
+ continue;
+
if (realloc_lhs)
{
/* Check to see if USE_STMT is a mismatched deallocation
// PR target/104213
// { dg-do compile }
// { dg-options "-Wuse-after-free" }
-// FIXME: We should not output the warning twice.
struct A
{
{
operator delete (this);
f (); // { dg-warning "used after" }
-} // { dg-warning "used after" }
+}