From bf93dba8e2058c64fc1140c9035bbf9bbe20bfdf Mon Sep 17 00:00:00 2001 From: Derek Mauro Date: Tue, 14 Jun 2022 12:48:22 -0700 Subject: [PATCH] counting_allocator: suppress bogus -Wuse-after-free warning in GCC 12 PiperOrigin-RevId: 454932630 Change-Id: Ifc716552bb0cd7babcaf416fe28462c15b4c7f23 --- absl/container/internal/counting_allocator.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/absl/container/internal/counting_allocator.h b/absl/container/internal/counting_allocator.h index 927cf082..66068a5a 100644 --- a/absl/container/internal/counting_allocator.h +++ b/absl/container/internal/counting_allocator.h @@ -80,7 +80,15 @@ class CountingAllocator { template void destroy(U* p) { Allocator allocator; + // Ignore GCC warning bug. +#if ABSL_INTERNAL_HAVE_MIN_GNUC_VERSION(12, 0) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wuse-after-free" +#endif AllocatorTraits::destroy(allocator, p); +#if ABSL_INTERNAL_HAVE_MIN_GNUC_VERSION(12, 0) +#pragma GCC diagnostic pop +#endif if (instance_count_ != nullptr) { *instance_count_ -= 1; }