Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MIR operators: clarify Shl/Shr handling of negative offsets
Browse files Browse the repository at this point in the history
RalfJung committed May 15, 2024

Verified

This commit was signed with the committer’s verified signature. The key has expired.
tvdeyen Thomas von Deyen
1 parent ac385a5 commit 335b5bb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions compiler/rustc_middle/src/mir/syntax.rs
Original file line number Diff line number Diff line change
@@ -1480,13 +1480,15 @@ pub enum BinOp {
BitOr,
/// The `<<` operator (shift left)
///
/// The offset is truncated to the size of the first operand and made unsigned before shifting.
/// The offset (RHS) is re-interpreted as an unsigned value of the same size and then truncated
/// to the size of the first operand before shifting.
Shl,
/// Like `Shl`, but is UB if the RHS >= LHS::BITS or RHS < 0
ShlUnchecked,
/// The `>>` operator (shift right)
///
/// The offset is truncated to the size of the first operand and made unsigned before shifting.
/// The offset (RHS) is re-interpreted as an unsigned value of the same size and then truncated
/// to the size of the first operand before shifting.
///
/// This is an arithmetic shift if the LHS is signed
/// and a logical shift if the LHS is unsigned.

0 comments on commit 335b5bb

Please sign in to comment.