Thread overview
[Issue 16708] opAssign and struct-member padding break comparison and invariants
Nov 21, 2016
Tomer Filiba
Nov 21, 2016
ZombineDev
Nov 21, 2016
Eyal Lotem
Nov 21, 2016
ag0aep6g@gmail.com
Dec 17, 2022
Iain Buclaw
November 21, 2016
https://issues.dlang.org/show_bug.cgi?id=16708

Tomer Filiba <tomerfiliba@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |industry

--
November 21, 2016
https://issues.dlang.org/show_bug.cgi?id=16708

ZombineDev <petar.p.kirov@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |petar.p.kirov@gmail.com

--
November 21, 2016
https://issues.dlang.org/show_bug.cgi?id=16708

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

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

--- Comment #1 from Eyal Lotem <eyal.lotem@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).

--
November 21, 2016
https://issues.dlang.org/show_bug.cgi?id=16708

ag0aep6g@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ag0aep6g@gmail.com

--- Comment #2 from ag0aep6g@gmail.com ---
I'd argue that equality should not compare the padding. See issue 16216.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=16708

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P2

--