Bug 7783 – compiler generated struct equality doesn't compare array fields

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-03-25T22:10:00Z
Last change time
2012-03-26T13:38:49Z
Assigned to
nobody
Creator
code

Comments

Comment #0 by code — 2012-03-25T22:10:53Z
cat > bug.d << CODE struct Foo { string name; bool b; } void main() { auto a = Foo("foobar".idup, true); auto b = Foo("foobar".idup, true); assert(a == b); } CODE dmd -run bug -------- The structures are compared bitwise which fails here.
Comment #1 by k.hara.pg — 2012-03-25T23:54:49Z
I think this is just same as bug 3789.
Comment #2 by bugzilla — 2012-03-26T00:37:49Z
In the absense of a user-defined opEquals for the struct, equality is defined as a bitwise compare. This is working as expected. Not a bug.
Comment #3 by bearophile_hugs — 2012-03-26T04:27:27Z
(In reply to comment #2) > In the absense of a user-defined opEquals for the struct, equality is defined > as a bitwise compare. This is working as expected. Not a bug. See my answer in Bug 3789 .
Comment #4 by code — 2012-03-26T13:38:49Z