curl-library
Re: curl_off_t suffix
Date: Fri, 15 Aug 2008 11:17:53 -0700
On Fri, Aug 15, 2008 at 06:44:58PM +0100, Jamie Lokier wrote:
> You're saying the compiler truncates a constant in this expression:
>
> (__int64_t) 123456789012345
>
> But _doesn't_ truncate it in this expression:
>
> (123456789012345 + (9223372036854775807LL - 9223372036854775807LL))
>
> That's pretty bizarre, truncating prior to cast, but not truncating
> prior to addition. Are you sure any compiler does that? Both
> addition and casts seem to have an equal footing in C's "arithmatic
> constant expressions". (Btw, C99 doesn't require the LL suffix to
> produce correct code, although I realise most of the compilers aren't C99).
That's not quite what I was saying. I meant that a long long literal like
that would be truncated if used where an int were expected, e.g.
int foo = 123456789012345; or a more complicated expression involving promoted
int literals. Both those contexts above are ones in which the compiler
will treat the literal to a signed 64-bit int, and I can't think of any
advantage of doing it one way or the other.
>>> Dan
-- http://www.MoveAnnouncer.com The web change of address service Let webmasters know that your web site has movedReceived on 2008-08-15