Re: [PATCH] block-sha1/sha1.c: silence compiler complaints by casting void* to uintptr_t
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 15, 2009, 01:46 UTC
- Message-ID
- <7v8whl7ss9.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <5HEgWEs64y4Ty7FnekstRP8Q71pNi_FTweLbMhYWc6zoZBA4jkJqpQ@cipher.nrlssc.navy.mil>
Brandon Casey <casey@nrlssc.navy.mil> writes:
Show 13 quoted lines
> Linus Torvalds wrote: >> I suspect it might as well be cast to "const char *", and then >> hopefully you only need one cast. >> >> So maybe it could be written as >> >> data = (const char *) data + len; >> >> instead, and avoid the second cast (because the assignment should be ok, >> since it's assigning back to a "const void *"). > > Yep, that's enough. It produces an identical binary on all platforms > except Solaris x86 using SUNWspro compiler.
Casting to "const char *" to tell compilers that we are interested in byte address differences/increments makes sense to me, but I do not know how to interpret your last comment.
Do you mean that SUNWspro compiler misbehave with the "cast to char *" and do you meed your "casting to uintptr_t to explicitly compute byte addresses as int" to make it behave?