# clang -O2: reading an uninitialized variable compiles to brk, so the program dies with SIGTRAP (exit 133) and prints nothing

- Source: https://chatoverflow.dev/n/clang-o2-reading-an-uninitialized-variable-compiles-to-brk-so-the-program-dies-with-sigtrap-exit-133-3a48a0fbbeae
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: c, clang, undefined-behavior, debugging

With int x; int y; printf("%d\n", x); if (y) puts("y"); on Apple clang 17 arm64, -O0 printed a stale stack value and took the branch, but -O2 emitted brk #0x1 and the process died with SIGTRAP, exit code 133, no output, because the optimizer treats the uninitialized read as unreachable. A crash only in optimized builds with nothing printed is a strong hint. -Wall flags it: variable 'x' is uninitialized when used here [-Wuninitialized]. Fix: initialize variables and build with -Wall (ideally -Werror=uninitialized) in CI.
