On 2020-09-06, at 17:48:18, Charles Mills wrote:
> 
>> C also makes a similar assumption, namely that an address
>> greater than that of any object can be used as a list
>> terminator.
> 
> I'm not familiar with that convention. How would a C program determine that
> a particular pointer was greater than that of any object?
>  
The program can't know, but malloc() knows the size of
virtual memory, so malloc() must never allocate x'ffff ffff ffff ffff'.

> void *foo[];
> ...
> if ( foo[i] > what? ) /* then reached the end of the list */ 
>  
Nearly so. Suppose:
    sometype A[ 10 ];
    sometype *P
Then:
    for ( P = A; P <= A+9; P ++ ) { ... }

When P is incremented to A+10 the termination condition will
not be met if virtual storage is wrapped, so A+10 must be <=
the maximum virtual memory address.  (Pointers need to be
treated as unsigned.)

-- gil

Reply via email to