Thursday, February 20, 2014

Demonstrable bug in C#

Hello,


You can look at the IL and the actual calculations from right to left and see that it's actually correct.


int i = 8;

int j = 4;


1)


j = /* 8 */ j ^ (i = /* 12 */ j ^ i); // j ^= i ^= j;

i = /* 4 */ j ^ i; // i ^= j;


2)


j = /* 0 */ j ^ (i = /* 4 */ i ^ (j = /* 12 */ j ^ i)); // j ^= i ^= j ^= i;


P.S. The brackets in the OP are kinda pointless.




Regards, Eyal Shilony


No comments:

Post a Comment