[Top][All Lists]

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

Re: Proposal: immediate strings

From: Paul Eggert
Subject: Re: Proposal: immediate strings
Date: Tue, 05 Jun 2012 23:41:19 -0700
User-agent: Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120430 Thunderbird/12.0.1

On 06/05/2012 11:14 PM, Dmitry Antipov wrote:
> The problem with ptrdiff_t is that it's signed (and has no unsigned version),
> and the code assumes that the bitfields are unsigned.

OK, but can't we then simply say 'unsigned int foo : N' where N is the
proper width?

> why ptrdiff_t
> (read: signed difference between pointers) is used for size values, although
> there is a special type ssize_t (and it's unsigned counterpart size_t)?

ssize_t is there mostly for historical reasons; it need not be as
wide as size_t (and on some ancient hosts is not).  It's best used
only when the POSIX API uses it.

Generally speaking we prefer signed types in Emacs source code, for
several reasons.  For example, comparisons work better (you don't get
strange results like zero is less than -1).  Another example: you can
trap signed integer overflow when debugging, and catch some bugs that way.
This is why we generally prefer ptrdiff_t to size_t.

reply via email to

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