diff --git a/tests/numerics/numeric_vector_test.h b/tests/numerics/numeric_vector_test.h index cb390114edd..92dbf809f64 100644 --- a/tests/numerics/numeric_vector_test.h +++ b/tests/numerics/numeric_vector_test.h @@ -13,6 +13,7 @@ #include #define NUMERICVECTORTEST \ + CPPUNIT_TEST( testCasting ); \ CPPUNIT_TEST( testLocalize ); \ CPPUNIT_TEST( testLocalizeBase ); \ CPPUNIT_TEST( testLocalizeIndices ); \ @@ -58,6 +59,25 @@ class NumericVectorTest : public CppUnit::TestCase { void tearDown() {} +#ifdef LIBMESH_HAVE_RTTI + template + void Casting() + { + // https://stackoverflow.com/questions/79192304/macos-xcode-16-breaks-dynamic-cast-for-final-types-defined-in-shared-library + // + // XCode 16.1 has a bug where a subclass declared final cannot be + // dynamically cast to a parent class. Let's make sure that + // doesn't affect this build. + + auto v_ptr = std::make_unique(*my_comm, global_size, local_size); + + Derived * d_ptr = dynamic_cast(v_ptr.get()); + libmesh_assert_msg(d_ptr, + "Dynamic cast failed on this system. XCode 16 bug?"); + CPPUNIT_ASSERT(d_ptr); + } +#endif + template void Operations() { @@ -355,6 +375,15 @@ class NumericVectorTest : public CppUnit::TestCase { Norms,DerivedClass>(); } + void testCasting() + { + LOG_UNIT_TEST; + +#ifdef LIBMESH_HAVE_RTTI + Casting,DerivedClass>(); +#endif // LIBMESH_HAVE_RTTI + } + void testOperations() { LOG_UNIT_TEST;