Ok, but if you look at the TypeInfo class in object.d [1], you'll see init() returns null.  Then if you look at the TypeInfo_i class for integers [2], it doesn't override init().  I, therefore, suspect some compiler special treatment.  So, how (and where in the source code) does an integer get it's 32-bit 0 initial value?

[1] https://github.com/D-Programming-Language/druntime/blob/master/src/object.d#L289
[2] https://github.com/D-Programming-Language/druntime/blob/master/src/rt/typeinfo/ti_int.d#L18
 
Mike



On Friday, June 12, 2015 3:58 AM, Steven Schveighoffer via dmd-internals <dmd-internals@puremagic.com> wrote:


I don’t know that the compiler cares what’s in the TypeInfo, it uses it’s own internal representation I think. This is a communication to druntime of how to initialize the type. The idea is not to take up data in the static section with zero bytes.


It’s probably used elsewhere too, but I’m not sure where to look.

-Steve

On Jun 11, 2015, at 8:02 AM, Mike Franklin via dmd-internals <dmd-internals@puremagic.com> wrote:

There is a comment [1] in object.d for TypeInfo.init reading:

"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."

Also, I see where the null pointer is set in typinf.c [2].  


Using int as an example, how does the compiler go from a null pointer and a size to a 32-bit 0?  Where is that done in the compiler?


[1] https://github.com/D-Programming-Language/druntime/blob/master/src/object.d#L286-L287
[2] https://github.com/D-Programming-Language/dmd/blob/master/src/typinf.c#L460


Thanks for the help,
Mike
_______________________________________________
dmd-internals mailing list
dmd-internals@puremagic.com
http://lists.puremagic.com/mailman/listinfo/dmd-internals


_______________________________________________
dmd-internals mailing list
dmd-internals@puremagic.com
http://lists.puremagic.com/mailman/listinfo/dmd-internals