|
|
|
|
|
by atq2119
559 days ago
|
|
The 3rd step can flush out compiler bugs, as follows. The 1st step uses gcc, so it's not going to find any bugs in this compiler. The 2nd step uses the compiler as compiled by gcc. That will find some bugs, such as crash bugs or missing features (like your for loop example). However, it does not find bugs that lead to generating incorrect code. The 3rd step uses the compiler compiled by itself. If there is a bug in code generation that led to the stage-2 compiler being compiled incorrectly, that is likely to lead to some error during stage-3 compilation, such as a crash. And if it doesn't crash outright, it is very likely to cause the resulting executable to differ between steps 2 and 3. The incorrectly compiled compiler is surely even worse at compiling correctly than the compiler that was presumably compiled correctly (using gcc)! So, this 3-step process is a pretty good way of finding bugs, especially if you compare the stage-2 result against the stage-3 result. |
|