IT lexicon Programming Undefined behavior

Undefined behavior UB

Programming På svenska → Updated: 2026-05-24

C/C++ code whose behaviour is not specified — the compiler may do anything, including deleting the code.

Classics: signed integer overflow, division by 0, use-after-free, reading uninitialised memory. The compiler optimises based on "UB never happens" — a mission-critical bug becomes a security hole. Sanitisers (ASAN, UBSAN) catch in tests. Rust eliminates most UB via language design.

← Back to the lexicon