I'm experiencing a very weird behaviour. Was unable to isolate the problem in a MCVE, but will when I'll progress on my investigation.
I have a program, based on CPPUNIT library and Qt that runs ~900 unit tests. This program is deployed on Android using QtCreator. It links with ~80 libraries, each one defining some tests.
On PC, the programs runs perfectly. When deployed on Android, when I run it, after some tests were ran (~100), I start getting std::bad_cast
exceptions for every dynamic_cast
done within my tests. I see it comes from places where I call dynamic_cast
on a pointer, not on a reference. According to the doc, std::bad_cast
is only thrown when dynamic_cast
is called on a reference...
void validate( ParentTestHelper& testHelper )
{
const ChildTestHelper* child = dynamic_cast<const ChildTestHelper*>( &testHelper );
...
}
However, my code throws std::bad_cast
.
If I run only the test doing the dynamic_cast
, it works. It will only fail if it is run after other ones...and running them manually one by one does not let me reproduce the problem. There must be something weird somewhere leading to this issue and I'm still investigating.
If anyone has an idea why dynamic_cast
called on a pointer could throw std::bad_cast
, this may help...