Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
'operator' used on polymorphic type 'type' with /GR-; unpredictable behavior may result
Remarks
You tried to use the dynamic_cast operator or typeid operator, which requires Run-Time Type Information (RTTI), without enabling it. To enable RTTI, recompile with /GR.
Example
The following example generates C4541:
// C4541.cpp
// compile with: /W1 /GR-
#include <typeinfo>
struct Base
{
virtual ~Base() {}
};
struct Derived : Base {};
int main()
{
Derived derived;
Base* pointer_to_base = &derived;
dynamic_cast<Derived*>(pointer_to_base); // C4541
typeid(*pointer_to_base); // C4541
typeid(pointer_to_base); // OK
}