[Issue 11817] Structs with void initialized fields get initialized anyway

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Apr 23 06:48:52 PDT 2016


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

Adam D. Ruppe <destructionator at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |destructionator at gmail.com

--- Comment #3 from Adam D. Ruppe <destructionator at gmail.com> ---
There's also struct and field padding, which is defined as being filled with
zeroes, so an initializer may have zeroes around it even if there's void.

But, if everything at the end, including padding, is void-initialized, the
.init could be truncated. If any code uses .init.length instead of .sizeof,
such code would be broken, but I think that code is broken already.

So the easy fix would be a truncated initializer - no holes in the middle (at
least not at this point), but a big hole in the end... just you have to make
sure there's no padding involved - the performance benefit would come only when
you properly align things and set that to void too, which isn't hard to do.

=void in the middle btw could just be zeroes in the initializer for now since
it is undefined anyway.

--


More information about the Digitalmars-d-bugs mailing list