From d66e0dc6cc3c0ce647a9c238aa30d7b867f87317 Mon Sep 17 00:00:00 2001 From: Derek Mauro Date: Tue, 14 Jun 2022 13:51:01 -0700 Subject: [PATCH] absl::Optional: suppress bogus -Wmaybe-uninitialized GCC 12 warning PiperOrigin-RevId: 454947125 Change-Id: Idbe6c8b4953c3d6147326bebc915d24dff83e7d5 --- absl/types/internal/optional.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/absl/types/internal/optional.h b/absl/types/internal/optional.h index 92932b60..6ed0c669 100644 --- a/absl/types/internal/optional.h +++ b/absl/types/internal/optional.h @@ -91,7 +91,15 @@ class optional_data_dtor_base { void destruct() noexcept { if (engaged_) { + // `data_` must be initialized if `engaged_` is true. +#if ABSL_INTERNAL_HAVE_MIN_GNUC_VERSION(12, 0) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif data_.~T(); +#if ABSL_INTERNAL_HAVE_MIN_GNUC_VERSION(12, 0) +#pragma GCC diagnostic pop +#endif engaged_ = false; } }