Skip to content
  • Arseny Kapoulkine's avatar
    e50672cf
    ubsan: Fix undefined behavior for signed left shift in compact mode · e50672cf
    Arseny Kapoulkine authored
    We were using << compact_alignment_log2 instead of * compact_alignment
    for symmetry with the encoding where >> is crucial to keep code fast and
    round to negative infinity.
    
    For decoding, the results are the same and any reasonable compiler
    should convert *4 into <<2 so just use a multiplication - that doesn't
    trigger UB on negative numbers.
    e50672cf
    ubsan: Fix undefined behavior for signed left shift in compact mode
    Arseny Kapoulkine authored
    We were using << compact_alignment_log2 instead of * compact_alignment
    for symmetry with the encoding where >> is crucial to keep code fast and
    round to negative infinity.
    
    For decoding, the results are the same and any reasonable compiler
    should convert *4 into <<2 so just use a multiplication - that doesn't
    trigger UB on negative numbers.
Loading