m-ou-se / rust-atomics-and-locks

Code examples, data structures, and links from my book, Rust Atomics and Locks.
Other
1.33k stars 120 forks source link

Minor issue explaining "Undefined Behavior" (offset of out-of-bound access) #55

Open IgorDzreyev opened 4 months ago

IgorDzreyev commented 4 months ago

Type of error

Minor technical mistake

Location of the error

https://marabos.nl/atomics/basics.html

Description of the error

Minor issue in explaing code for "Undefined Behavior ":

let a = [123, 456, 789]; let b = unsafe { a.get_unchecked(index) };

... It [access] might result in reading from memory whatever was stored in the bytes right after a. ...

Looks like it is 3 * size of i32 (12) bytes after a ...