You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a note in the standard library documentation regarding the impl std::ops::Div<i32> for i32 (source), which states that a division by zero panics (irregardless of whether being in debug mode or not):
This operation will panic if other == 0 or the division results in overflow.
However, as discussed on URLO, this only seems to guarantee that e.g. 1.div(0) panics, but it (formally) doesn't make any statement regarding the primitive operation 1 / 0.
The section "Arithmetic and Logical Binary Operators" should be extended and state that integer division by zero panics (irregardless of whether being compiled with debug mode).
Maybe, the behavior on overflow due to signed integer division should also be documented in the reference (which, according to std::ops::Div, is also guaranteed to panic).edit: This is already documented in the "Overflow" subsection.
The text was updated successfully, but these errors were encountered:
The PR title was bad, but I think what was committed isn't outright incorrect because the † is in the column headed 'Integer' and not in the column headed 'Floating point'.
But it would be clearer to say "integer" in the text like in the note about rounding to zero.
While there is a section on overflow behavior, which discusses that integer overflows will trigger a panic in debug mode, the section "Arithmetic and Logical Binary Operators" doesn't specify what happens when an integer division by zero is encountered.
There is a note in the standard library documentation regarding the
impl std::ops::Div<i32> for i32
(source), which states that a division by zero panics (irregardless of whether being in debug mode or not):However, as discussed on URLO, this only seems to guarantee that e.g.
1.div(0)
panics, but it (formally) doesn't make any statement regarding the primitive operation1 / 0
.The section "Arithmetic and Logical Binary Operators" should be extended and state that integer division by zero panics (irregardless of whether being compiled with debug mode).
Maybe, the behavior on overflow due to signed integer division should also be documented in the reference (which, according toedit: This is already documented in the "Overflow" subsection.std::ops::Div
, is also guaranteed to panic).The text was updated successfully, but these errors were encountered: