1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-01-18 20:39:35 +02:00

Mention panics vs wrap-around for integer overflows (#901)

Fixes #894
This commit is contained in:
Martin Geisler 2023-07-04 12:31:16 +02:00 committed by GitHub
parent f4f0e7a1f3
commit d0223ad98b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,14 +3,15 @@
No undefined behavior at runtime:
* Array access is bounds checked.
* Integer overflow is defined.
* Integer overflow is defined (panic or wrap-around).
<details>
Key points:
* Integer overflow is defined via a compile-time flag. The options are
either a panic (a controlled crash of the program) or wrap-around
* Integer overflow is defined via the [`overflow-checks`](https://doc.rust-lang.org/rustc/codegen-options/index.html#overflow-checks)
compile-time flag. If enabled, the program will panic (a controlled
crash of the program), otherwise you get wrap-around
semantics. By default, you get panics in debug mode (`cargo build`)
and wrap-around in release mode (`cargo build --release`).