Why would an initialised struct pointer field be null in the struct's destructor?

Stanislav Blinov via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun May 21 07:13:20 PDT 2017


On Sunday, 21 May 2017 at 12:48:10 UTC, Adam D. Ruppe wrote:
> On Saturday, 20 May 2017 at 10:48:54 UTC, Gary Willoughby wrote:
>> 		// Why is this._foo null here???
>
> The others have answered why and what to do, but note that 
> according to the spec, that any struct should be able to have 
> its destructor called, so you should do a null check in there 
> anyway.

Not if you either emplace() or blit Foo.init into all of the 
array elements.


More information about the Digitalmars-d-learn mailing list