array !is null fails
ao at pathlink.com
Mon Feb 12 23:14:08 PST 2007
Reply to John,
> BCS wrote:
>> this works:
>> assert((cast(char*)null)[0..0] !is null);
>> this dosn't
>> assert((cast(char*)null)[0..10] !is null);
>> DMD v1.005 linux
>> Am I missing somthing?
> Seems like a safety thing to me. If an array has a non-zero length,
> the still points at null, you shouldn't be looking at it.
That's why it's in the assert
> A zero
> length array is always valid, however. A zero-length array is still
> an array, not null... depending on your definition.
Ah... I though that [i..i].length == 1?
> Dunno what the implications of such a discontinuity are, but you could
> just use .ptr or (!is null && .length > 0) if you want.
What good is the (array !is null) if it doesn't tell you when the pointer
More information about the Digitalmars-d-learn