Re: [PATCH] C undefined behavior fix

Date: Thu Jan 03 2002 - 01:29:04 EST

> Now the claim is that RELOC is bad because it adds an offset to a
> pointer, and the offset is usually around 0xc0000000, and thus we are
> "violating" the C standard. Thus we are being told that someday this
> will break and cause a lot of grief. My contention is that this will
> only break if a pointer becomes something other than a simple address
> and pointer arithmetic becomes something other than simple 2's
> complement addition, subtraction, etc. If that happens then C will
> have become useless for implementing a kernel, IMHO.
Well, pointer arithmetic on the HPPA isn't simple 2's complement due to
the way implicit space register selection works.

For example in an unscaled indexed addressing mode like

ldbx srcreg1(srcreg2), dstreg

Is not equivalent to

ldbx srcreg2(srcreg1), dstreg

ie x + y != y + x for computing an address in a memory operation.

For the same reason computing an address outside of an object into a
register, then using a displacement in a memory operation to generate an
address that is within the bounds of the object may not work. ie, you
can't do something like this and expect it to work:

int a[10];
int *z = a - 10;

  return z[10];

And before anyone says the PA is unbelievably strange and nobody else would
make the same mistakes -- the mn10300 (for which a linux port does exist)
has the same failings.


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

This archive was generated by hypermail 2b29 : Mon Jan 07 2002 - 21:00:20 EST