[PATCH] Fixes -fsanitize=undefined warning about left-shifting a negative signed value.

Alexey Samsonov vonosmas at gmail.com
Fri Jan 9 15:46:44 PST 2015


I've just encountered the same problem - it seems to be the last failure in
UBSan bootstrap of check-llvm testsuite (and mailed
http://reviews.llvm.org/D6908).

On Thu, Jan 8, 2015 at 2:06 PM, Artem Belevich <tra at google.com> wrote:

> I've attached the patch.
>
> The issue is that ubsan spotted a case where we extract 21 bits from a
> negative signed addend value in order to encode it into binary
> representation of reloc.
>
> While behavior is harmless in this case, technically it does fall under
> undefined behavior. The patch extracts relevant bits into an unsigned
> variable first and then uses that unsigned value to shift bits around.
>
> --Artem
>
> On Thu, Jan 8, 2015 at 1:46 PM, Chandler Carruth <chandlerc at google.com>
> wrote:
>
>> FYI, could you attach the patch file rather than including it inline, or
>> post it using Phabricator[1]?
>>
>> [1]: http://llvm.org/docs/Phabricator.html
>>
>>
>> --
> --Artem Belevich
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>


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


More information about the llvm-commits mailing list