The following managed c++ code generates wrong IL code. This leads to an Access violation.public ref class Test{public: int CompilerBugMethod() { int nTickCount = 0; Object^ obj = gcnew Object(); if(System::Environment::TickCount > 50) { nTickCount = System::Environment::TickCount; } String^ strObjToString = obj->ToString(); return nTickCount; }};int main(array<System::String ^> ^args){ Test^ test = gcnew Test(); test->CompilerBugMethod(); return 0;}---> IL Code:.method public hidebysig instance int32 CompilerBugMethod () cil managed { // Method begins at RVA 0x1000 // Code size 28 (0x1c) .maxstack 4 IL_0000: ldc.i4.0 IL_0001: newobj instance void [mscorlib]System.Object::.ctor() IL_0006: call int32 [mscorlib]System.Environment::get_TickCount() IL_000b: ldc.i4.s 50 IL_000d: ble.s IL_0015 IL_000f: pop IL_0010: call int32 [mscorlib]System.Environment::get_TickCount() IL_0015: callvirt instance string [mscorlib]System.Object::ToString() IL_001a: pop IL_001b: ret} // end of method Test::CompilerBugMethod
Visual Studio/Team Foundation Server/.NET Framework Tooling Version
Steps to reproduce
Product Language
Operating System
Operating System Language
Actual results
Expected results