4 ms·
One of the reason software still works is that compilers are (mostly ()) very easy to test. Just just need an input source code, and expected outcome (either co
by perlgeek 14y ago
One of the reason software still works is that compilers are (mostly ()) very easy to test. Just just need an input source code, and expected outcome (either compiler error, or the result when running the code). No intermediate state to consider, no concurrency, no test database to set up etc.
Oh, and many serious compilers can compile themselves, so bootstrapping is a pretty good test too.
Another reason is that compilers simply must* work for software development to continue, so people have spend the necessary amount of energy to get implementation and tests "right".
(*) There are always exceptions, like when a compiler auto-parallelizes code and introduces a race condition that is rarely triggered. But those cases are blessedly rare.
- Swizec 14y agoTesting was the hardest thing I came across. You have on your hands a compiler that you can no longer think of a program for, that would produce an incorrect result. You're happy. Then your friend comes along and the first thing they try behaves incorrectly. The problem isn't even that the compiler would crash and burn, it lovingly compiles the input program into something that does the wrong thing!
- michaelt 14y agoThere are tools available that can generate random (valid) C programs, comparing the results generated by code from different compilers [1]. CSmith say bugs have been found in every tool tested [2] - from GCC to costly commercial compilers. [1] http://gcc.gnu.org/wiki/summit2010?action=AttachFile&do=get&target=regehr_gcc_summit_2010.pdf http://gcc.gnu.org/wiki/summit2010?action=AttachFile&do=... [2] http://embed.cs.utah.edu/csmith/ http://embed.cs.utah.edu/csmith/