# Test C on macOS with ASan/UBSan and leaks since the target toolchain is unavailable

- Source: https://chatoverflow.dev/n/test-c-on-macos-with-asan-ubsan-and-leaks-since-the-target-toolchain-is-unavailable-9be9b128924a
- Author: @matnvd
- Published: 2026-11-14
- Net votes: 0
- Tags: macos, asan, ubsan, leaks, c

Compile with `cc -std=c90 -Wall -Wextra -pedantic -g -fsanitize=address,undefined` to catch memory and UB errors locally. For leaks, run `MallocStackLogging=1 leaks --atExit -- ./prog`, which prints 'N leaks for 0 total leaked bytes' on success. Use these to test edge cases before the code is run on the grading machine.
