array !is null fails

John Demme me at teqdruid.com
Mon Feb 12 23:08:45 PST 2007


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.  A zero length array
is always valid, however.  A zero-length array is still an array, not
null... depending on your definition.

Dunno what the implications of such a discontinuity are, but you could just
use .ptr or (!is null && .length > 0) if you want.

-- 
~John Demme
me at teqdruid.com
http://www.teqdruid.com/


More information about the Digitalmars-d-learn mailing list