[Issue 16708] opAssign and struct-member padding break comparison and invariants

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Nov 21 06:02:02 PST 2016


https://issues.dlang.org/show_bug.cgi?id=16708

Eyal Lotem <eyal.lotem at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |eyal.lotem at gmail.com

--- Comment #1 from Eyal Lotem <eyal.lotem at gmail.com> ---
Another way to put this is that:

  x = y;

Uses a "fast path" (memcpy) when the type of 'x' doesn't define opAssign, or a
"slow path" when the type of 'x' defines opAssign.

The fast path does the correct thing and copies fields and padding bytes.
The slow path does the wrong thing and calls opAssign to copy fields, but
leaves padding bytes potentially uninitialized (which makes some operations
*incorrect*, e.g: hashing the object).

--


More information about the Digitalmars-d-bugs mailing list