VC 7.1 bug in IJW --- calling native virtual methods returning bool from managed code

B

Bern McCarty

What do you make of this? I cannot tell for sure but it almost seems as
the the transition thunk to get back from the native bool method to the managed
caller is looking at eax and, if any bit is set, normalizing it to 0x00000001.
If it wants to normalize the value then it should only operate on the al
register since that's all that the native bool method uses to hold the return
value.

Is this a known VC 7.1 bug? Is there a hotfix available?


//
// compile with VC 7.1 like this:
//
// cl /clr main.cpp
//

#using <mscorlib.dll>
#using <System.dll>

#pragma unmanaged
class NativeTypePOD
{
public: bool IsRenderable() { return false; }
};

class NativeTypeNonPOD
{
public: virtual bool IsRenderable() { return false; }
};

#pragma managed


__gc class ManagedType
{
private: NativeTypePOD* m_nativePODType;
private: NativeTypeNonPOD* m_nativeNonPODType;

public: ManagedType::ManagedType()
{
m_nativePODType = new NativeTypePOD();
m_nativeNonPODType = new NativeTypeNonPOD();
}

public: __property bool get_IsRenderablePOD()
{
bool retval = m_nativePODType->IsRenderable();
return retval;
}

public: __property bool get_IsRenderableNonPOD()
{
bool retval = m_nativeNonPODType->IsRenderable();
return retval;
}

};



int main(int argc, char* argv[])
{
ManagedType* mt1 = new ManagedType();

bool condition1 = mt1->IsRenderablePOD;
bool condition2 = mt1->IsRenderableNonPOD;

System::Console::WriteLine(S"This first one works:");
System::Console::WriteLine(S"Calling native bool non-virtual method hardwired
to return false : {0}", __box(condition1));
System::Console::WriteLine(S"\nThis second one fails:");
System::Console::WriteLine(S"Calling native bool virtual method hardwired
to return false : {0}", __box(condition2));
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top