Static foreach pull request

Stefan Koch via Digitalmars-d digitalmars-d at puremagic.com
Wed May 10 06:18:35 PDT 2017


On Wednesday, 10 May 2017 at 13:11:46 UTC, Atila Neves wrote:
> On Wednesday, 10 May 2017 at 11:12:06 UTC, Stefan Koch wrote:
>> 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

What do you mean ?
Hmm this should be how it works ....
They reason why assert([] == null) holds.
is because base is implicitly alias thised.

if you try assert([] is null), it should fail.


More information about the Digitalmars-d mailing list