Based on this answer...
Finding the type of an object in C++
...I wrote this code:
static TVALUE getUpperBou
dynamic_cast only throws exceptions on failure if its template argument is a reference type.
When it's a pointer type, dynamic_cast instead evaluates to NULL on failure.
This is made very clear in the preferred language reference, for which you could simply have Googled:
5c) Otherwise, the runtime check fails. If the
dynamic_castis used on pointers, the null pointer value of type _new_type_ is returned. If it was used on references, the exceptionstd::bad_castis thrown.
I also don't understand why you expect an int to be thrown, rather than something that derives std::exception. Perhaps you were hoping that return in a try block jumps to the matching catch block? It doesn't.