[Issue 2990] TypeInfo.init() returns invalid array

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jan 7 06:49:11 PST 2011


http://d.puremagic.com/issues/show_bug.cgi?id=2990


Steven Schveighoffer <schveiguy at yahoo.com> changed:

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


--- Comment #1 from Steven Schveighoffer <schveiguy at yahoo.com> 2011-01-07 06:46:51 PST ---
This is really a documentation issue.  The init() is correct, as I discovered
when fixing a recent bug.

Essentially, when the ptr is null, but the length is non-zero, the meaning is
that the init value for that type is init().length bytes of zero.  This cuts
down on having to store an array of zeros in the binary.

The documentation for init() says:

"Return default initializer, null if default initialize to 0"

Which seems to indicate init() should return null if default initializer should
be zero.  But a null array has length == 0.

I think the right solution to this is to change the documentation:

"Return default initializer.  If the type should be initialized to all zeros,
an array with a null ptr and a length equal to the type size will be returned"

Sound good?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list