Zig gives the programmer direct access to memory, integers, pointers, and machine operations. This makes many programs simple and efficient. It also makes some operations...
| Section | Title |
|---|---|
| 1 | Undefined Behavior |
| 2 | Safety Checks |
| 3 | Pointer Casts |
| 4 | Integer Overflow |
| 5 | Volatile Memory |
| 6 | Packed Memory |
| 7 | FFI Safety |
| 8 | Exercises |
Undefined BehaviorZig gives the programmer direct access to memory, integers, pointers, and machine operations. This makes many programs simple and efficient. It also makes some operations...
Safety ChecksZig inserts safety checks for operations that are valid only under certain conditions. These checks are present in safe build modes. They catch mistakes at the point where the...
Pointer CastsA pointer has a type.
Integer OverflowAn integer type can store only a fixed range of values.
Volatile MemoryMost memory in a program behaves normally.
Packed MemoryA normal struct is laid out for efficient access.
FFI SafetyFFI means foreign function interface. It is the boundary where Zig calls code written in another language, or where another language calls Zig.
ExercisesExercise 19-1. Write a program that overflows a u8 using +=. Run it in Debug mode and observe the panic.