diff --git a/src/TNL/Pointers/SharedPointerHost.h b/src/TNL/Pointers/SharedPointerHost.h index 27945b0587fea0b18bba31e75c030326ab755944..a71fd36872bb4547f11b852f120898070ffed888 100644 --- a/src/TNL/Pointers/SharedPointerHost.h +++ b/src/TNL/Pointers/SharedPointerHost.h @@ -440,10 +440,21 @@ protected: free() { if( this->pd ) { + // As far as we know, GCC 12.0.0 and 12.1.0 issue a false-positive use-after-free warning + // These bug reports may be related: + // - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105327 + // - https://bugzilla.redhat.com/show_bug.cgi?id=2047715 +#if defined( __GNUC__ ) && ! defined( __clang__ ) && ! defined( __NVCC__ ) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wuse-after-free" +#endif if( ! --this->pd->counter ) { delete this->pd; this->pd = nullptr; } +#if defined( __GNUC__ ) && ! defined( __clang__ ) && ! defined( __NVCC__ ) + #pragma GCC diagnostic pop +#endif } }