On Sat, Jan 17, 2004 at 12:11:36AM -0800, Ben Reser wrote:
> On Sat, Jan 17, 2004 at 12:07:19AM -0500, Greg Hudson wrote:
> > >   const apr_off_t min = (apr_off_t) 1 << ((sizeof (apr_off_t)*8)-1);
> > 
> > The behavior of this expression is undefined by C99.  If we're going
> > to rely on common signed overflow behavior, "if ((apr_off_t) *offset
> > == *offset)" would appear to be simpler.
> > 
> > I'm not sure if there's a good way to perform this check which is
> > totally standards-conformant.  C99 allows two's-complement,
> > one's-complement, and sign-and-magnitude representation of integers.
> > It would be nice if APR would help us out by defining *_MIN and *_MAX
> > constants for apr_off_t, but it doesn't; moreover, it looks like it
> > would have a difficult job doing so, since there are apparently no
> > system constants for the minimum or maximum off_t value.
> 
> I'd say the comparision test looks brilliant.  My only concern is will a
> compiler optimize it out?
> 
It would take a very smart compiler.  Regardless: this is a single compare
and branch; it's not the end of the world.
--ben
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Jan 17 15:13:05 2004