Re: [PATCH v2] add, rm, mv: fix bug that prevents the update of non-sparse dirs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 26, 2021 at 11:17 PM Derrick Stolee <stolee@xxxxxxxxx> wrote:
(regarding a pointer that "backs up one before the beginning
of the array" as it were)

> I also see the specification saying this is undefined, but I do not
> understand how any reasonable compiler/runtime could do anything
> other than store "path - 1" as if it was an unsigned integer. ...

This Standard C rule dates back to old segmented systems.
If you put some array A into its own segment, and use only
the offset as the "pointer", and the segment offset starts at
zero, then A[0] is at "address zero".  So the imaginary element
at A[-1] is at "address max", and a loop like:

    for (p = &A[N]; p >= &A[0]; p--)

is an infinite loop.

In practice nobody is using these architectures today, but the
restriction still exists.

Chris



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux