Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test for dynamic_cast compiler bug #4015

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions tests/numerics/numeric_vector_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <memory>

#define NUMERICVECTORTEST \
CPPUNIT_TEST( testCasting ); \
CPPUNIT_TEST( testLocalize ); \
CPPUNIT_TEST( testLocalizeBase ); \
CPPUNIT_TEST( testLocalizeIndices ); \
Expand Down Expand Up @@ -58,6 +59,25 @@ class NumericVectorTest : public CppUnit::TestCase {
void tearDown()
{}

#ifdef LIBMESH_HAVE_RTTI
template <class Base, class Derived>
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<Derived>(*my_comm, global_size, local_size);

Derived * d_ptr = dynamic_cast<Derived *>(v_ptr.get());
libmesh_assert_msg(d_ptr,
"Dynamic cast failed on this system. XCode 16 bug?");
CPPUNIT_ASSERT(d_ptr);
}
#endif

template <class Base, class Derived>
void Operations()
{
Expand Down Expand Up @@ -355,6 +375,15 @@ class NumericVectorTest : public CppUnit::TestCase {
Norms<libMesh::NumericVector<libMesh::Number>,DerivedClass>();
}

void testCasting()
{
LOG_UNIT_TEST;

#ifdef LIBMESH_HAVE_RTTI
Casting<libMesh::NumericVector<libMesh::Number>,DerivedClass>();
#endif // LIBMESH_HAVE_RTTI
}

void testOperations()
{
LOG_UNIT_TEST;
Expand Down