Checking if a string is null

Frits van Bommel fvbommel at
Wed Jul 25 22:50:07 PDT 2007

Derek Parnell wrote:
> On Wed, 25 Jul 2007 14:29:47 +0100, Regan Heath wrote:
>> Aside: If the location and length are identical you can short-circuit 
>> the compare, returning true and ignoring the content, this could save a 
>> bit of time on comparisons of large arrays.
> I don't think this is such a good idea. How does one address the array of
> four bytes at RAM location 4?

I'm pretty sure the only way to obtain such an array would be to have 
already invoked Undefined Behavior (assuming 4 is an invalid memory 
location on the platform the program's running on) and as such it 
doesn't really matter whether or not two array references to it compare 
equal or not...

More information about the Digitalmars-d-learn mailing list