Subject: Re: Making counts and lengths unsigned
To: Charles M. Hannum <mycroft@MIT.EDU>
From: Rhialto <rhialto@falu.nl>
List: tech-kern
Date: 04/15/2006 21:20:20
On Fri 14 Apr 2006 at 12:58:45 -0400, Charles M. Hannum wrote:
> There are places where arithmetic is done with m_len and a signed
> (possibly negative) value.  This would have to be done with extreme
> care -- just switching the type is very likely to introduce bugs.

In a completely unrelated piece of software, there was an expression
that accessed a stack like fp[-foo-bar+baz] and one of those was an
unsigned int. Thanks to the "viral" effect of unsigned combined with
sign extension, this went wrong on 64-bit architectures, where it worked
ok by the accident of wrap-around on 32 bits. So one needs to be very
careful with this sort of thing.

-Olaf.
-- 
___ Olaf 'Rhialto' Seibert      -- You author it, and I'll reader it.
\X/ rhialto/at/xs4all.nl        -- Cetero censeo "authored" delendum esse.