[PATCH] ADT: Remove misaligned pointeres from DenseMapInfo

Chandler Carruth chandlerc at gmail.com
Mon Dec 29 17:28:05 PST 2014


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141229/533a599a/attachment.html>


More information about the llvm-commits mailing list