bug-gnulib
[Top][All Lists]
Advanced

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

Re: source(builtin) and read(2)


From: Paul Eggert
Subject: Re: source(builtin) and read(2)
Date: Thu, 29 Mar 2007 16:06:32 -0700
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

"Clive D.W. Feather" <address@hidden> writes:

> ptrdiff_t has to be able to hold the largest difference between two
> pointers; it is a signed type.

The C standard does not require this.  It allows an implementation,
for example, where size_t is 64 bits, ptrdiff_t is 32, and objects can
be created with more than 2**32 bytes.  The behavior is undefined
if you subtract two pointers into a same object and the resulting
value does not fit into ptrdiff_t.  See section 6.5.6 of the standard.

My vague recollection is that ssize_t and SSIZE_MAX were put in
precisely to support screwy implementations like Tandem.  But
this was a while ago and I wasn't there, so I could well be wrong.

Also, ptrdiff_t and ssize_t were invented by different committees.
Quite possibly they didn't want to step on each others' toes or assume
each others' work.  Early POSIX did not assume C89, so it couldn't
assume ptrdiff_t.  This most likely explains why there are two types.

It'd be nice if someone wrote up the definitive story on this and put
it into the POSIX rationale....





reply via email to

[Prev in Thread] Current Thread [Next in Thread]