[dmd-beta] Struct Comparision WTF: Is the new or old behavior right?

David Simcha dsimcha at gmail.com
Sat Dec 10 09:24:40 PST 2011

On 12/10/2011 3:25 AM, kenji hara wrote:
> You can use s is S.init for bitwise comparison.

That gives me the same results as using ==.  I ended up working around 
my immediate problem in Plot2kill by using memcmp, but in general this 
behavior needs to be better specified.

I was not even aware that `is` was defined for anything other than 
pointers/class references before this conversation.   As you implicitly 
suggested, I think `is` should be defined for all types and should mean 
"guaranteed to return true iff lhs is bitwise identical to rhs.  Will 
not dereference pointers, will not call opEquals, will not return false 
because of NaNs".

Also, the behavior of == _must_ be consistent on 32- and 64-bit.  Since 
I know this definitely is a bug, I'll file a report for it.

More information about the dmd-beta mailing list