Thread overview
[Issue 13678] TypeInfo.init is inconsistent
Jul 02, 2015
Mike
Dec 15, 2015
ZombineDev
Dec 15, 2015
ZombineDev
[Issue 13678] TypeInfo.initializer is inconsistent
Jan 18, 2016
Marco Leise
Dec 17, 2022
Iain Buclaw
July 02, 2015
https://issues.dlang.org/show_bug.cgi?id=13678

Mike <slavo5150@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |slavo5150@yahoo.com

--- Comment #1 from Mike <slavo5150@yahoo.com> ---
https://github.com/D-Programming-Language/druntime/pull/1307 may provide a solution to this.

--
December 15, 2015
https://issues.dlang.org/show_bug.cgi?id=13678

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

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

--
December 15, 2015
https://issues.dlang.org/show_bug.cgi?id=13678

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|preapproved                 |

--
December 15, 2015
https://issues.dlang.org/show_bug.cgi?id=13678

Steven Schveighoffer <schveiguy@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy@yahoo.com

--- Comment #2 from Steven Schveighoffer <schveiguy@yahoo.com> ---
init.ptr is null means that the data should be initialized to zero.

As far as I know, there is no mechanism to say you shouldn't initialize the data.

That being said, I can agree that all of the cases above should have null pointers for init (soon to be called initializer). No reason to store those zeros in the data segment.

--
January 18, 2016
https://issues.dlang.org/show_bug.cgi?id=13678

Marco Leise <Marco.Leise@gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|TypeInfo.init is            |TypeInfo.initializer is
                   |inconsistent                |inconsistent

--- Comment #3 from Marco Leise <Marco.Leise@gmx.de> ---
(In reply to Steven Schveighoffer from comment #2)
> As far as I know, there is no mechanism to say you shouldn't initialize the data.

That is correct and my thinking is that this was due to the .init/.initializer property being underspecified, since we do have it in the language:

  struct Output
  {
      double[1024] data = void;
  }

Instead of:

null => initializer is all zeroes
array of correct length => initializer contains non-zero bytes

we could also define three states:

ptr is null, length is correct => initializer is all zeroes
ptr is null, length == 0 => initializer is void
else => initializer contains non-zero bytes

This would allow us to avoid a memset where the data structure is explicitly declared with all void initializers.

Where the type is statically known, 'x = T.init' can still be more effective, because the compiler can freely chose how to initialize a data structure, based on whether x is already initialized or not, T.init contains a mix of void and non-void fields or if one or more of the fields are overwritten shortly after. typeid(T).initializer is the more blunt tool. T.init is a compiler intrinsic, typeid(T).initializer is data.

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

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--