any_test: expand the any emplace bug suppression,

since it has gotten worse in GCC 12

PiperOrigin-RevId: 455128070
Change-Id: Ia866e59d4e2e810aea16afe492d58013c5661a2b
pull/1200/head
Derek Mauro 3 years ago committed by Copybara-Service
parent 2e36d96669
commit a184bab83f
  1. 33
      absl/types/any_test.cc

@ -754,26 +754,23 @@ TEST(AnyTest, FailedCopy) {
// Test the guarantees regarding exceptions in emplace. // Test the guarantees regarding exceptions in emplace.
TEST(AnyTest, FailedEmplace) { TEST(AnyTest, FailedEmplace) {
{ BadCopyable bad;
BadCopyable bad; absl::any target;
absl::any target; ABSL_ANY_TEST_EXPECT_BAD_COPY(target.emplace<BadCopyable>(bad));
ABSL_ANY_TEST_EXPECT_BAD_COPY(target.emplace<BadCopyable>(bad)); }
}
{ // GCC and Clang have a bug here.
BadCopyable bad; // Ine some cases, the exception seems to be thrown at the wrong time, and
absl::any target(absl::in_place_type<int>); // target may contain a value.
ABSL_ANY_TEST_EXPECT_BAD_COPY(target.emplace<BadCopyable>(bad)); #ifdef __GNUC__
#if defined(ABSL_USES_STD_ANY) && defined(__GLIBCXX__) TEST(AnyTest, DISABLED_FailedEmplaceInPlace) {
// libstdc++ std::any::emplace() implementation (as of 7.2) has a bug: if an #else
// exception is thrown, *this contains a value. TEST(AnyTest, FailedEmplaceInPlace) {
#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());
#endif #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 } // namespace

Loading…
Cancel
Save