3 ms·
When I was writing the code generation part of a compiler in a previous lifetime, there were a number of conversations of the following sort early on in the pro
by wglb 13y ago
When I was writing the code generation part of a compiler in a previous lifetime, there were a number of conversations of the following sort early on in the production life of the compiler:
Programmer: The compiler is producing the wrong code for this case.
Compiler team: Ok, let's look at the code and step through it.
Programmer: So it is putting this quantity in the register pair here
Compiler team: Right.
Programmer: and it is taking out the high byte and putting it there
Compiler team: Right.
Programmer: and then it is . . . Oh. Wow, that is a weird way to do this.
Compiler team: Right. Saves two bytes of code.
The programming team had previously used assembler and had developed conventions of code patterns. Our boss pointed out that "A compiler should produce assembly code that an assembly programmer would be fired for writing."
Not that we didn't have bugs, but the previous conversation was more common than the code generation bugs we had.
And if, Team Compiler, if you think that that compiler is always right, John Regehr http://blog.regehr.org/ http://blog.regehr.org/ has some news for you.