โ C17 MOC ยท ๐ฏ Mission ยท ๐ Resources ยท ๐ Teacher Notes
C17 Glossary
[!NOTE] Canonical Language Canonical definitions for ISO C17 concepts, memory rules, compiler behaviors, systems architecture, and vault concept mappings.
Language Semantics & Compiler Behaviors
Undefined Behavior (UB)
Behavior upon use of a non-portable or erroneous construct for which the ISO C standard imposes no requirements; the compiler is free to assume UB never happens and optimize accordingly (which can cause silent miscompilations, crashes, or security vulnerabilities).
- Vault Concept: Concept: Defensive Programming & Invariants
- Avoid: Random error, crash behavior, compiler glitch
Implementation-Defined Behavior
Unspecified behavior where each conforming implementation (compiler + OS target) must document how the choice is made (e.g. size of long, representation of signed negative numbers).
- Avoid: Undefined behavior, portable choice
Unspecified Behavior
Behavior where the standard provides two or more possibilities and imposes no requirement on which is chosen in any instance (e.g. order of evaluation of function arguments).
- Avoid: Undefined behavior
Sequence Point
A point in the execution sequence at which all side effects of previous evaluations are complete and no side effects from subsequent evaluations have taken place (in C11/C17 formalized as the "sequenced-before" partial order).
- Avoid: Execution step, clock tick
Storage Classes, Linkage & Lifetimes
Variable Linkage
The property of an identifier that determines whether it refers to the same object or function across different translation units (external linkage) or only within the current translation unit (internal linkage).
- Vault Concept: Concept: Variable Linkage
- Reference: Advanced C: Storage Classes
- Avoid: Scope, pointer exposure
Internal Linkage
Linkage specified by the static keyword at file scope; restricts the identifier's visibility to its own translation unit (.c file), preventing name collisions and enforcing modular encapsulation.
- Vault Concept: Concept: C Static
- Avoid: Private variable, local scope
External Linkage
Linkage possessed by default file-scope variables and non-static functions, or explicitly declared with extern; allows identifiers to be referenced across multiple translation units during the linking phase.
- Vault Concept: Concept: C Extern
- Avoid: Public variable, global export
Automatic Storage Duration
Storage duration where objects are allocated on the function stack frame upon block entry and automatically deallocated upon block exit (auto storage class).
- Vault Concept: Concept: Automatic Storage Duration
- Reference: Concept: C Auto
- Avoid: Dynamic allocation, heap memory
Static Storage Duration
Storage duration where an object is allocated in the program's data or BSS segment prior to program startup (main()) and persists for the entire program execution lifetime.
- Vault Concept: Concept: Variable Lifetime
- Reference: Concept: C Static
- Avoid: Global lifetime, permanent stack
Register Storage Class
A storage class specifier (register) hinting to the compiler that an automatic variable should be stored in a CPU register for fast access; in ISO C, applying the address-of operator (&) to a register variable is a compile-time constraint violation.
- Vault Concept: Concept: Register Storage
- Reference: Concept: C Register
- Avoid: CPU variable, hardware register
Memory Model, Structs & Pointer Mechanics
Alignment
A hardware/ABI requirement that an object of a given type be stored at a memory address that is an exact multiple of its size or natural alignment boundary (e.g. a 4-byte uint32_t aligned to a multiple of 4).
- Vault Concept: Diagnostic: Struct Memory Layout & Alignment
- Avoid: Spacing, memory offset
Struct Padding and Tail Padding
Unused padding bytes inserted automatically by the compiler between struct members (internal padding) and at the end of a struct (tail padding) to ensure members and contiguous array elements maintain natural alignment boundaries.
- Vault Concept: Diagnostic: Struct Padding & Tail Padding
- Avoid: Dead space, struct gap
Array Decay
The implicit conversion in C where an expression of array type (T[N]) is rewritten by the compiler to a pointer to its first element (T*) in almost all expression contexts (except sizeof, _Alignof, and &).
- Vault Concept: [[Grill/C Systems Programming#Round 4: Array Decay &
sizeofMechanics|Diagnostic: Array Decay]] - Avoid: Pass by reference, array pointer
Strict Aliasing Rule
A compiler optimization rule stating that two pointers of different types (with specific exceptions like char* and uint8_t*) cannot point to the same memory location, allowing the compiler to reorder reads/writes across them.
- Avoid: Pointer collision, duplicate referencing
Effective Type
The type assigned to an allocated object in memory that governs which pointer types may legitimately read or write to it under strict aliasing rules.
- Avoid: Variable type, cast type
Type Punning
The practice of accessing a block of memory through a pointer of a different type or through a union to reinterpret its raw bit representation.
- Avoid: Force casting, byte hacking
Flexible Array Member (FAM)
An unbounded array defined as the last member of a struct (e.g. int data[];), used in C99/C11/C17 to allocate dynamically sized structures in a single contiguous memory block.
- Avoid: Zero-length array (
[0]), trailing pointer
CPU Architecture & Virtual Machine Execution
Endianness & Big-Endian Opcode Packing
The byte ordering of multi-byte numbers in memory. In big-endian systems (such as CHIP-8 opcodes), the most significant byte is stored at the lowest memory address; 16-bit opcodes are reconstructed via (mem[PC] << 8) | mem[PC + 1].
- Vault Concept: Concept: CHIP-8 Fetch
- Reference: Diagnostic: Bitwise Operations & Endianness
- Avoid: Byte flipping, reverse reading
Jump Table
An array of code addresses or function pointers indexed directly by an integer opcode or event type to achieve $O(1)$ instruction dispatch without branch misprediction cascades.
- Vault Concept: Diagnostic: Function Pointers & Jump Tables
- Avoid: Multi-switch, branching ladder
Direct Threaded Code (Computed Gotos)
An interpreter dispatch technique utilizing compiler extensions (such as GNU C &&label and goto *ptr) where every opcode instruction routine handles its own dispatching directly to the next handler, eliminating the central loop switch and reducing CPU branch predictor pipeline stalls.
- Vault Concept: Concept: Computed Gotos in C (Direct Threaded Code)
- Avoid: Multi-threading, threaded execution
Diagnostics & Tooling
AddressSanitizer (ASan)
A fast memory error detector tool (enabled via -fsanitize=address) that instruments memory accesses at compile-time to detect out-of-bounds accesses, use-after-free, double-free, and leaks.
- Vault Concept: Reference: Modern C17 Toolchain & CMake
- Avoid: Valgrind replacement, leak detector
UndefinedBehaviorSanitizer (UBSan)
A compile-time instrumentation tool (enabled via -fsanitize=undefined) that catches undefined behaviors at runtime such as signed integer overflow, null pointer dereference, and misaligned pointers.
- Vault Concept: Reference: Modern C17 Toolchain & CMake
- Avoid: Linter, static checker
