mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-15 05:26:47 +00:00
Clarify when MIR Div
/Rem
trigger UB
This commit is contained in:
parent
73f104b6d6
commit
adb37d4999
@ -1272,13 +1272,18 @@ pub enum BinOp {
|
||||
Mul,
|
||||
/// The `/` operator (division)
|
||||
///
|
||||
/// Division by zero is UB, because the compiler should have inserted checks
|
||||
/// prior to this.
|
||||
/// For integer types, division by zero is UB, as is `MIN / -1` for signed.
|
||||
/// The compiler should have inserted checks prior to this.
|
||||
///
|
||||
/// Floating-point division by zero is safe, and does not need guards.
|
||||
Div,
|
||||
/// The `%` operator (modulus)
|
||||
///
|
||||
/// Using zero as the modulus (second operand) is UB, because the compiler
|
||||
/// should have inserted checks prior to this.
|
||||
/// For integer types, using zero as the modulus (second operand) is UB,
|
||||
/// as is `MIN % -1` for signed.
|
||||
/// The compiler should have inserted checks prior to this.
|
||||
///
|
||||
/// Floating-point remainder by zero is safe, and does not need guards.
|
||||
Rem,
|
||||
/// The `^` operator (bitwise xor)
|
||||
BitXor,
|
||||
|
Loading…
Reference in New Issue
Block a user