3 ms·
When this comes up, I like to quote Dennis Ritchie on `noalias`: “the committee is planting timebombs that are sure to explode in people's faces”; “a license fo
by kps 3y ago
When this comes up, I like to quote Dennis Ritchie on `noalias`: “the committee is planting timebombs that are sure to explode in people's faces”; “a license for the compiler to undertake aggressive optimizations that are completely legal by the committee's rules, but make hash of apparently safe programs”, and consequently: “[It] must go. This is non-negotiable. [...] It negates every brave promise X3J11 ever made about codifying existing practices, preserving the existing body of code, and keeping (dare I say it?) ‘the spirit of C.’”
This is what ‘undefined behavior’ turned out to be, so it's clear to me that the consequences of the definition were not understood at the time.
- tialaramex 3y agoDennis is correct about there being timebombs, but the problem was the timebombs were already planted, by him and his colleagues. X3J11 codified them via the "Undefined Behaviour" mechanism, but the alternative isn't to keep K&R C and "not have" undefined behaviour, you just leave a gaping hole in the language. Foundationally C is unsound. For its purpose this made real sense - who cares about soundness, we need to ship Unix ASAP? But with unsound foundations nothing built upon them can be sound itself. ANSI and eventually ISO C finds a way to write the unsound language down formally but doing so doesn't fix it, Mother Nature isn't fooled by words. In places where WG14 declined to write formal language excusing the unsound nonsense (such as provenance rules), there's still unsound nonsense, it's just not written in the ISO document. Again, Mother Nature doesn't care, programs with either kind of unsound nonsense malfunction, the fact that one kind is written down on paper and the other isn't makes no practical difference.