I came across a bug in code that is only reproduced when the code is built with optimizations enabled. I\'ve made a console app that replicates the logic for testing (code
This bug seems to have been fixed in .NET 4 (beta 2). Here's the optimized x86 disassembly for the bit nobugz highlighted, above:
Console.WriteLine("Post-check Value is: " + value);
00000056 mov ecx,dword ptr ds:[033C2090h]
0000005c mov edx,dword ptr [ebp-8]
0000005f call 65D8FE10
The program also displays the expected output in both optimized and unoptimized modes.