Compiler bug

From Free net encyclopedia

A compiler bug is a particularly insidious form of computer bug.

A compiler is a computer program that translates a computer program written in one computer language (called the source language) into a program written in another computer language (called the output or the target language).

In the common case, an ordinary computer bug (e.g., division by zero) often manifests itself as a report that a particular error has occurred. Programming errors (e.g., using + instead of -) may merely produce the wrong answer. In the case of a compiler bug, the result may be to translate the source program incorrectly, so that when the program runs it produces the wrong answer or some error message that does not really relate to the original program. As well as translating your program, some compilers also attempt to optimize it, so that it will run faster, or use less memory, or both. This optimization is often the most complicated part of a compiler, and hence is likely to have the most bugs.

Examples of compiler bugs:

  • One vendor offers four different levels of compiler optimization. In the section of the manual discussing optimization, it says "use the highest workable optimization level", and then goes on to provide an example where use of the highest level can cause a program to fail.
  • The language and compiler allowed declarations of the form "const real ApproxPi = 355/113;" If you used this within a subroutine everything worked perfectly. But if one were to use it in a global context then ApproxPi had the value 1.0 instead of the expected 3.141592, problems would ensue.
  • In a batch-mode compiler, you could select whether or not you got a program listing. But if you switched off the listing to save disk space, then bad code was generated.