[LLVMdev] We need better hashing

Jay Foad jay.foad at gmail.com
Wed Feb 15 02:15:19 PST 2012


On 14 February 2012 10:44, Chris Lattner <clattner at apple.com> wrote:
>  /// Add a pointer value
>   template<typename T>
>   void add(const T *PtrVal) {
>     addImpl(
>         reinterpret_cast<const uint32_t *>(&PtrVal),
>         reinterpret_cast<const uint32_t *>(&PtrVal + 1));
>   }

> Also, addImpl is dereferencing the pointers as
> uint32_t's, but there is nothing that guarantees that T is a multiple of 4
> bytes.

I think you've misread the code. We're not passing PtrVal to addImpl,
we're passing &PtrVal. So the constraint is that the pointer type
"const T *" must be at least as aligned as a uint32_t, which seems
safe.

Jay.




More information about the llvm-dev mailing list