Source: abseil
Version: 0~20210324.2-4.
Followup-For: Bug #1012885
X-Debbugs-Cc: nathan.teodo...@canonical.com

Dear Maintainer,

I'm forwarding the from upstream patch to fix this issue.

Already committed to Ubuntu Kinetic (LP: #1991253[1])

[1]: https://launchpad.net/bugs/1991253
From: Derek Mauro <dma...@google.com>
Date: Wed, 15 Jun 2022 07:42:49 -0700
Subject: [PATCH] any_test: expand the any emplace bug suppression, since it
 has gotten worse in GCC 12
Applied-Upstream: commit: a184bab83ffcffc2aaac49a3900361158ab3890f

PiperOrigin-RevId: 455128070
Change-Id: Ia866e59d4e2e810aea16afe492d58013c5661a2b
---
 absl/types/any_test.cc | 33 +++++++++++++++------------------
 1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/absl/types/any_test.cc b/absl/types/any_test.cc
index 70e4ba22b1..d382b927c2 100644
--- a/absl/types/any_test.cc
+++ b/absl/types/any_test.cc
@@ -754,26 +754,23 @@ TEST(AnyTest, FailedCopy) {
 
 // Test the guarantees regarding exceptions in emplace.
 TEST(AnyTest, FailedEmplace) {
-  {
-    BadCopyable bad;
-    absl::any target;
-    ABSL_ANY_TEST_EXPECT_BAD_COPY(target.emplace<BadCopyable>(bad));
-  }
+  BadCopyable bad;
+  absl::any target;
+  ABSL_ANY_TEST_EXPECT_BAD_COPY(target.emplace<BadCopyable>(bad));
+}
 
-  {
-    BadCopyable bad;
-    absl::any target(absl::in_place_type<int>);
-    ABSL_ANY_TEST_EXPECT_BAD_COPY(target.emplace<BadCopyable>(bad));
-#if defined(ABSL_USES_STD_ANY) && defined(__GLIBCXX__)
-    // libstdc++ std::any::emplace() implementation (as of 7.2) has a bug: if 
an
-    // exception is thrown, *this contains a value.
-#define ABSL_GLIBCXX_ANY_EMPLACE_EXCEPTION_BUG 1
-#endif
-#if defined(ABSL_HAVE_EXCEPTIONS) && \
-    !defined(ABSL_GLIBCXX_ANY_EMPLACE_EXCEPTION_BUG)
-    EXPECT_FALSE(target.has_value());
+// GCC and Clang have a bug here.
+// Ine some cases, the exception seems to be thrown at the wrong time, and
+// target may contain a value.
+#ifdef __GNUC__
+TEST(AnyTest, DISABLED_FailedEmplaceInPlace) {
+#else
+TEST(AnyTest, FailedEmplaceInPlace) {
 #endif
-  }
+  BadCopyable bad;
+  absl::any target(absl::in_place_type<int>);
+  ABSL_ANY_TEST_EXPECT_BAD_COPY(target.emplace<BadCopyable>(bad));
+  EXPECT_FALSE(target.has_value());
 }
 
 }  // namespace

Reply via email to