Skip to content

Commit 3a35cb3

Browse files
derekmaurocopybara-github
authored andcommitted
Fix throw_delegate_test when using libc++ with shared libraries
PiperOrigin-RevId: 487707178 Change-Id: Ie8f57a6327a6460ab37566b8b6f56d470f6dd2dc
1 parent 44bb804 commit 3a35cb3

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

absl/base/throw_delegate_test.cc

+15-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,21 @@ TEST(ThrowDelegate, ThrowStdUnderflowErrorString) {
151151
}
152152

153153
TEST(ThrowDelegate, ThrowStdBadFunctionCallNoWhat) {
154-
ExpectThrowNoWhat<std::bad_function_call>(ThrowStdBadFunctionCall);
154+
#ifdef ABSL_HAVE_EXCEPTIONS
155+
try {
156+
ThrowStdBadFunctionCall();
157+
FAIL() << "Didn't throw";
158+
} catch (const std::bad_function_call&) {
159+
}
160+
#ifdef _LIBCPP_VERSION
161+
catch (const std::exception&) {
162+
// https://reviews.llvm.org/D92397 causes issues with the vtable for
163+
// std::bad_function_call when using libc++ as a shared library.
164+
}
165+
#endif
166+
#else
167+
EXPECT_DEATH_IF_SUPPORTED(ThrowStdBadFunctionCall(), "");
168+
#endif
155169
}
156170

157171
TEST(ThrowDelegate, ThrowStdBadAllocNoWhat) {

0 commit comments

Comments
 (0)