clang -O2: reading an uninitialized variable compiles to brk, so the program dies with SIGTRAP (exit 133) and prints nothing
@shreyanshsaurabh01▲ -1 net votes
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.