git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] block-sha1/sha1.c: silence compiler complaints by casting void* to uintptr_t

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
Aug 15, 2009, 02:34 UTC
Message-ID
<MecVLMUB15cEJQiZpwSBg9ysnmFSB1QYZfIQuSOStnFx2KoeScNXGQ@cipher.nrlssc.navy.mil>
In-Reply-To
<7v8whl7ss9.fsf@alter.siamese.dyndns.org>
Junio C Hamano wrote:
Show 17 quoted lines
> Brandon Casey <casey@nrlssc.navy.mil> writes:
> 
>> 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,
Yes, I agree.
> 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?

No, sorry, the SUNWspro compiler produces a working binary with any of the three versions: the original, cast to uintptr_t, or cast to const char*. Though it emits a warning with the original.

I was just pointing out that the SUNWspro compiler does not produce an identical binary on x86 for each of the three versions like the GNU compiler does.

Sorry for the confusion. Linus's suggestion of casting to "const char*" should be adopted.

-brandon
Previous: Junio C HamanoNext: Junio C Hamano
Message 12 of 15 in “block-sha1: more good unaligned memory access candidates”
  1. block-sha1: more good unaligned memory access candidatesNicolas Pitre, Aug 13, 2009
  2. Linus TorvaldsAug 13, 2009
  3. Nicolas PitreAug 13, 2009
  4. Junio C HamanoAug 13, 2009
  5. Linus TorvaldsAug 13, 2009
  6. Nicolas PitreAug 13, 2009
  7. block-sha1/sha1.c: silence compiler complaints by casting void* to uintptr_tBrandon Casey, Aug 14, 2009
  8. Johannes SchindelinAug 15, 2009
  9. Linus TorvaldsAug 15, 2009
  10. Brandon CaseyAug 15, 2009
  11. Junio C HamanoAug 15, 2009
  12. Brandon CaseyAug 15, 2009
  13. Junio C HamanoAug 15, 2009
  14. Linus TorvaldsAug 15, 2009
  15. Brandon CaseyAug 15, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.