Hi, 

After a code review, we decided to change the line ("rootGrammar" is of type 
"Grammar*"):

SchemaGrammar* grammar = (SchemaGrammar*)rootGrammar;

to: 

SchemaGrammar* grammar = dynamic_cast<SchemaGrammar*>(rootGrammar);

As, we believe that using dynamic_cast (we're developing on the win32 platform, with 
vc6), is the most correct way to cast between types in the same inheritance chain (we 
use dynamic_cast exclusively in our project). 

The only problem is that the latter method fails (whereas the former method never 
failed), throwing an exception and returning 0, and yes, the "Grammar" object we're 
trying to down-cast is fully initialized. The compiler options are set to support 
RTTI, so I'm really failing to see what's wrong here. The stack at the time of failure 
looks as follows:

KERNEL32! 77e8f142()
MSVCRTD! _CxxThrowException@8 + 57 bytes
MSVCRTD! __RTDynamicCast + 383 bytes
rfw::XMLPLCBuilder::createDataTypeMapping() line 335 + 23 bytes

It is impossible to trace into the dynamic_cast, so it seems I'm left with very few 
options on how to go about to fix this, or at least understand why this fails. Has 
anybody else experienced this?

Everything seems ok, the Grammar class is abstract, and seems to be a polymorphic 
type, and no warnings or errors occur at compile-time.

Any hints or tips are greatly appreciated

Cheers

Mario 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to