[llvm-bugs] [Bug 28294] New: UB in APInt::slt

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jun 24 11:52:22 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=28294

            Bug ID: 28294
           Summary: UB in APInt::slt
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Support Libraries
          Assignee: unassignedbugs at nondot.org
          Reporter: jonathan at codesourcery.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

When VAL has its MSbit set, the left shift on line 558 shifts a negative value
leftward, which is UB. Similarly for RHS.VAL on line 559:

555: bool APInt::slt(const APInt& RHS) const {
556:   assert(BitWidth == RHS.BitWidth && "Bit widths must be same for
comparison");
557:   if (isSingleWord()) {
558:     int64_t lhsSext = (int64_t(VAL) << (64-BitWidth)) >> (64-BitWidth);
559:     int64_t rhsSext = (int64_t(RHS.VAL) << (64-BitWidth)) >>
(64-BitWidth);
560:     return lhsSext < rhsSext;
561:   }

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160624/158f72ed/attachment-0001.html>


More information about the llvm-bugs mailing list