Skip to content

Commit 05fce40

Browse files
authored
Add about overflow-checks flag in release mode
1 parent 47dd576 commit 05fce40

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/coding-guidelines/types-and-traits.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,18 @@ Types and Traits
1414
:category: types
1515
:recommendation: required
1616

17-
Code must not rely on Rust's implicit integer wrapping behavior that occurs in release builds.
18-
Instead, explicitly handle potential overflows using the standard library's checked,
17+
Code must not rely on Rust's implicit integer wrapping behavior that may occur in release
18+
builds. Instead, explicitly handle potential overflows using the standard library's checked,
1919
saturating, or wrapping operations.
2020

2121
.. rationale::
2222
:id: rat_kYiIiW8R2qD1
2323
:status: draft
2424

2525
In debug builds, Rust performs runtime checks for integer overflow and will panic if detected.
26-
However, in release builds (with optimizations enabled), integer operations silently wrap
27-
around on overflow, creating potential for silent failures and security vulnerabilities.
26+
However, in release builds (with optimizations enabled), unless the flag overflow-checks is
27+
turned on, integer operations silently wrap around on overflow, creating potential for silent
28+
failures and security vulnerabilities.
2829

2930
Safety-critical software requires consistent and predictable behavior across all build
3031
configurations. Explicit handling of potential overflow conditions improves code clarity,

0 commit comments

Comments
 (0)