[PATCH] ADT: Remove misaligned pointeres from DenseMapInfo

Alexey Samsonov vonosmas at gmail.com
Mon Dec 29 17:33:59 PST 2014


On Mon, Dec 29, 2014 at 5:28 PM, Chandler Carruth <chandlerc at gmail.com>
wrote:

>
> On Mon, Dec 29, 2014 at 5:06 PM, Alexey Samsonov <vonosmas at gmail.com>
> wrote:
>
>> > IIRC, the problem was that this is not actually undefined behavior. The
>> resulting pointer value might be a "trap representation", but that's
>> implementation-defined behavior, not undefined behavior. UBSan might need
>> to be fixed here.
>>
>>
>> What fix do you suggest? UBSan prints an error report when the unaligned
>> pointer T* is actually used, not when it's created. In LLVM, this "use" is
>> usually an upcast to Value *. So, you may treat UBSan as the tool
>> implementing this trapping behavior.
>
>
> I think the idea is that casting between pointers doesn't introduce UB, it
> is dereferencing the pointer, incrementing it, or otherwise using the
> pointer in some way other than to cast it to another pointer type or to an
> integer type (or to the void type) which is UB. UBSan is probably just a
> bit too aggressive here.
>

Casing (int*) to (float*) doesn't dereference a pointer. However,
upcast/downcast (in general case) does dereference a pointer - you may need
to read vtable and adjust the pointer value accordingly.

-- 
Alexey Samsonov
vonosmas at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141229/88ce0f58/attachment.html>


More information about the llvm-commits mailing list