← Back to /cpp/

Undefined behaviour: the C/C++ hall of shame_

Collecting the most surprising, dangerous, and instructive examples of undefined behaviour in C and C++.

By: dave_runtime Mar 22, 2026 5 posts
#5 Mar 22

Signed Integer Overflow is UB

In C and C++, signed integer overflow is undefined behaviour — not wrap-around. Compilers exploit this to eliminate overflow checks entirely when optimizing. Use unsigned types or compiler flags like -fwrapv if you need wrap semantics.

By: dave_runtime Mar 22, 2026 18:39
[1] [2] Page 2 of 2 (5 posts)
5 posts in this thread [+] Reply