3 ms·
Compilers (and thus, compiler writers, i.e., people) have gone off the deep end with C. In search of endless over-optimization (don't worry, they will tell you
by Upvoter33 9y ago
Compilers (and thus, compiler writers, i.e., people) have gone off the deep end with C. In search of endless over-optimization (don't worry, they will tell you that this optimization is "important" because some stupid benchmark runs 21% faster), programmer intent (as well as mistakes) are turned into bizarro behavior. Why we accept this is beyond me. For C, in particular, it has made writing code that uses plain old C ints way more challenging than it needs to be, among other things. We need to rethink what is important: a little more performance, or representing (to our best possible guess) what the programmer actually intended. </rant>
- tom_mellior 9y ago> representing (to our best possible guess) what the programmer actually intended. If the programmer intended to write a correct program, and the programmer wrote an undefined program instead, you should blame the programmer, not the compiler.
- maxlybbert 9y ago> We need to rethink what is important: a little more performance, or representing (to our best possible guess) what the programmer actually intended. I remember reading an old book about implementing a compiler. The book actually recommended that compilers should make an effort to fix simple mistakes; e.g., compilers should add semicolons if needed, check whether an undefined variable or function was actually a misspelled variable or function, etc. I wasn't sure whether I should laugh at the naivety or shudder about what kind of code that would have led to. Especially given that each compiler would be lenient in different ways from competing compilers.
- umanwizard 9y agoThis is basically what happened in real life with HTML, with the results you predict.
- umanwizard 9y agoDo you have an example of an optimization pass you would turn off in Clang? I mean, do you actually know which one you'd turn off and what the pros and cons are. Not just answer like "of course, whichever one caused this behavior!" I'm asking because I noticed nobody who rants about compiler behavior on UB code actually seems to have a detailed understanding of what they're talking about. They always seem to just be shooting from the hip.