7/30/2026 at 10:15:24 AM
Undefined behavior was, in most cases, intended to encompass a point where different implementations behaved in reasonable ways. In case of overflow, some implementations wrapped, some saturated, some threw an exception, some jumped to an interrupt handler, and some returned 0. They made it undefined intending to encompass all of these. Notice they are all fairly reasonable (except for returning 0).Later, stupid compiler writers decided that since the wording allows anything to happen, it also allows time travel or memory corruption. These are not reasonable, but they are allowed by the wording of the standard.
The standard should be fixed to say it returns an undefined value or activates an error handling mechanism. Nobody could argue that time travel is an error handling mechanism.
by inigyou
7/30/2026 at 10:19:15 AM
> They made it undefined intending to encompass all of these.Why wouldn't implementation-defined behavior suffice in this case?
by aw1621107
7/30/2026 at 10:34:52 AM
IB means the implementation has to fully document what it does. Evidently they didn't want to impose that requirement.by inigyou
7/30/2026 at 10:42:47 AM
There's always unspecified behavior if documentation is considered to be too onerous.by aw1621107
7/30/2026 at 11:50:52 AM
It also means that the behavior needs to be stable across time and that tools cannot report this behavior as a bug.by UncleMeat