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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to