3 ms·
> As for why to make things like signed overflow undefined vs implementation defined, we could argue about it. If you've got a link to something more than specu
by jcranmer 4y ago
> As for why to make things like signed overflow undefined vs implementation defined, we could argue about it. If you've got a link to something more than speculation about that choice, I'd like to read it. My opinion shouldn't be terribly valuable to anyone.
I'm (slowly) working on a "In Defense of UB" blog post, and I'm going to see if I can track down some old C committee members who might be able to offer more than speculation here. But I can't guarantee it, this is about discussions that happened well over 3 decades ago, and there's a good chance that recollections of details from that time are imperfect or just plain missing.
- xscott 4y agoI'll be eager to read that when you're done. I doubt I'll agree with your thesis, but still :-) I just went and skimmed the forward from an early version of "The C Programming Language" book [0]. There's certainly mention of writing portable programs, but UB as a device doesn't seem to be in there. And who knows what passed for "portability" in the early 70s - with enough preprocessor conditionals, you could have completely separate programs in the same file. > I'm going to see if I can track down some old C committee members I'll be interested in what they say, but any committee of more than one person is going to have varying beliefs and motivations. I'm sure you wouldn't do this, but it'd be possible to emphasize the examples that support your position while neglecting other view points. I also hope you'll at least consider Dennis Ritchie's perspective on the topic. Since he created the language, I think his opinion should carry more weight than most others. I haven't tracked the whole history of how "noalias" became "restrict", but he pretty clearly thought "noalias" was an "abomination" that created "hash of apparently safe programs". [1] At the very least, I think it shows he was opposed to making "hash" in the name of optimizations. I had no idea this debate has been going on since 1988. I guess compiler writers have been insane for much longer than I knew. [0] https://archive.org/details/TheCProgrammingLanguageFirstEdition/page/n9/mode/2up https://archive.org/details/TheCProgrammingLanguageFirstEdit... [1] https://groups.google.com/g/comp.lang.c/c/K0Cz2s9il3E/m/YDyo_xaRG5kJ https://groups.google.com/g/comp.lang.c/c/K0Cz2s9il3E/m/YDyo...