Static foreach pull request

Atila Neves via Digitalmars-d digitalmars-d at puremagic.com
Wed May 10 06:11:46 PDT 2017


On Wednesday, 10 May 2017 at 11:12:06 UTC, Stefan Koch wrote:
> On Wednesday, 10 May 2017 at 09:42:53 UTC, Timon Gehr wrote:
>> [...]
>
> So here is the difference between null and []:
>
> null :
>
> () { Slice* s; s = null; return s; }
>
> [] :
> () { Slice* s; s = alloca(sizeof(*s)); s.base = null; s.length 
> = 0; return s; }
>
> Therefore
>
> null.length => (cast(Slice*)null).length; which results in a 
> segfault.
>
> and
>
> [].length => (cast(Slice*)somevalidSliceDiscriptor).length;

That's not how "regular" D works though.

Atila


More information about the Digitalmars-d mailing list