I've got a code
byte[] bytes = new byte[] { 0x80, 1, 192, 33, 0 };
if (bytes[0] != 0x80 || ((bytes[1] & ~1) != 0) || bytes[4] != 0)
{
//signature wrong (.net 4.0 result)
}
else
{
//signture okay (.net 3.5 result)
}
In .net 3.5 expression evaluates as false, but in 4.0 it evaluates as true. My question is why? and how can i check all of my old (.net 3.5) code to prevent this behaviour?
So it's not lost in the comments, I believe you have hit a bug in RyuJIT, the new JIT compiler for 64 bit applications in .NET 4.6.
This is not the first one, for example see this blog post showing how the Stack Overflow team tracked down another issue.
As discussed in the comments, it is not triggered if you target .NET 3.5, nor if you target x86 in .NET 4.
This bug may or may not have been reported to Microsoft yet - if anyone is aware of a bug report for this, or has .NET 4.6 installed to track down the underlying cause more, feel free to edit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With