Question about building hash values from pointers
Ian Lance Taylor
iant@google.com
Mon Jun 2 04:03:00 GMT 2008
Andrew Haley <aph@redhat.com> writes:
> Ian Lance Taylor wrote:
>> Andrew Haley <aph@redhat.com> writes:
>>
>>> Richard Guenther wrote:
>>>> On Fri, May 30, 2008 at 10:57 AM, Kai Tietz <Kai.Tietz@onevision.com> wrote:
>>>>> Hi,
>>>>>
>>>>> as I noticed, most hash value calculations are trying to use pointer
>>>>> values for building the value and assume that a long/unsigned long scalar
>>>>> is wide enough for a pointer. This is at least for w64 target not true. So
>>>>> I want to know, if it would be good to introduce an gcc specific type for
>>>>> those kind of casts, or to use ssize_t/size_t.?
>>>> it's uintptr_t which should be used, if only as an intermediate cast -
>>>> (unsigned long)(uintptr_t)ptr.
>>> That's not possible because, IIRC, gcc must compile on C90 systems.
>>
>> We can just test for it with autoconf and typedef it if we don't have
>> it. We can figure out what to typedef it to by comparing the sizeof
>> void* to the sizeof the integer types--we already gather these sizes
>> in the configure script anyhow, and use them in hwint.h.
>
> Given that all this seems to be about is avoiding warning messages on
> some extremely unlikely architectures on which gcc may not run, I have
> to question the sens of such heavyweight measures. Why not simply use
> size_t? It would be adequate on every architecture anyone here knows
> about.
I don't personally find these measures to be heavyweight. I find them
to be fairly routine for the kind of portability we aim for. Only one
person has to get them right once.
But I'm fine with using size_t also, if it does the right thing on
W64.
Ian
More information about the Gcc
mailing list