cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: 64/32/16bit curl_off_t for _WIN32_WCE and ILEC400

From: Jamie Lokier <jamie_at_shareable.org>
Date: Tue, 3 Jun 2008 15:34:12 +0100

Yang Tse wrote:
> 2008/6/3, Jamie Lokier wrote:
>
> > Are there any platforms / compilers where the 64-bit integer types
> > cannot be added / subtracted from a pointer?
>
> Compilers with segmented memory models can play all kind of tricks.
> These under some configurations cut some corners for speed sake, even
> pointers might not be capable of addressing more than a certain amount
> of memory and adding a big offset to them results in pointer wrapping
> instead of addressing of another segment.
>
> I suppose that under this peculiar circumstances the compiler should
> 'warn real hard' but I have no first hand facts to show you.

It's fine for pointers to do strange things if you add an offset whose
value moves it _outside_ the array it's pointing to. That's not
allowed by C89 anyway, and it's rare for code to do it, except as a
temporary calculation (add X, subtract Y) - and that usually works out
fine even on segmented architectures.

So that's not a reason to limit the offset type size.

A proper reason (imho) would be adding an offset whose value doesn't
move it outside the array, but the _offset type_ causes the
calculation to go wrong.

Are there any architectures like that?

-- Jamie
Received on 2008-06-03