Created
January 15, 2014 20:55
-
-
Save VladimirReshetnikov/8444468 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
unsafe struct S | |
{ | |
public void* ptr; | |
public object obj; | |
static void Main() | |
{ | |
S s = default(S); | |
Console.WriteLine(Equals(s, s)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Interesting, why struct with only one pointer or with pointer and value type behaves correctly?
I assume that you ideas is correct, but in case when struct doesn't contains reference type fast version of
Equals
method is used:It seems that
CanCompareBits
return true only when struct contains reference type but returns true if struct contains unsafe pointer, and this comment from Rotor is not accurate: