18 ms·
The compiler has deduced that a comparison of a pointer to null makes no sense, because it was dereferenced; if that code is reached, the comparison will always
by kazinator 8y ago
The compiler has deduced that a comparison of a pointer to null makes no sense, because it was dereferenced; if that code is reached, the comparison will always be true. That should be diagnosed, just like, say, an unsigned-type > 0 comparison that is always true.
> why are you using C?
For detailed control of the machine with minimal run-time support, without resorting to assembly language. Basically, the original reasons for C, before all this historic revisionism.
I want reasonable speed: good use of registers and basic optimizations like jump threading and peephole code improvements. Optimization in C is otherwise the job of the programmer. The machine code should more or less follow from the calculations that are written in the source, and every memory access through pointers should be there, in the order it appears.
The "trust the programmer" mantra never meant "trust that there is no undefined behavior" but simply "trust that the programmer put every every expression in place for a reason and just translate it to machine code".
- mpweiher 8y ago>> why are you using C? > For detailed control of the machine with minimal run-time support, without resorting to assembly language. Exactly. C is about low-level control. That's why operating systems are written in C and numeric codes in FORTRAN, and not the other way around. Speed is something C enables for the programmer to obtain via the low-level control, not something it provides by trying to read your mind. > Basically, the original reasons for C, before all this historic revisionism. Yes, the revisionism is really, really frustrating. Too bad I can only upvote you once.
- deleted 8y ago[deleted]
- deleted 8y ago[deleted]