It's my understanding that the constructors of a type which have no fields are "statically allocated" and GHC shares these between all uses, and that the GC will not move these.
If that's correct then I would expect uses of reallyUnsafePtrEquality#
on values like False
and Nothing
to be very safe (no false negatives or positives), because they can only be represented as identical pointers to the single instance of that constructor.
Is my reasoning correct? Are there any potential gotchas, or reasons to suspect that this could become unsafe in near future versions of GHC?
I actually managed to get
reallyUnsafePtrEquality
to do the wrong thing.Here's my minimal code example
And doing something like
So... yes,
reallyUnsafePtrEquality
is still evil.