[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: apr_off_t is of an ambiguous size.

From: Ben Reser <ben_at_reser.org>
Date: 2004-01-17 09:11:36 CET

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?

-- 
Ben Reser <ben@reser.org>
http://ben.reser.org
"Conscience is the inner voice which warns us somebody may be looking."
- H.L. Mencken
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Jan 17 09:12:17 2004

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.