After a recent webinar, someone stayed online to talk more about compilers. They were surprised by the complexity and potential safety impact of the compiler – “To be honest, I thought it was just a translator.” As we have often mentioned before, a compiler is much more than that. It’s why testing your compiler is so important.

On one level it’s true – translating source code to executable code is what a compiler does. But since that happens quickly and without much interaction, many people fail to appreciate how complex compilers really are. A typical GCC or LLVM compiler is made up of around 5 million lines of source code created by thousands of developers all over the world. GCC launched its beta in 1987, 32 years ago, and just passed its 200th (congratulations!) release. The `youngster’ LLVM compiler was first released in 2003 and has now, at seventeen, achieved an impressive track record of its own. For proprietary compilers, the story is not much different. These are mind-boggling, long-term software development projects.

Throughout the years, the complexity of C and C++ compilers has increased massively, not only due to the updates of the language standards, but also because target processors have become more complex. To maximize their computing efficiency they often include special instructions, such as vector instructions, for specialized tasks. Making optimum use of instruction sets is also a critical part of compiler development, which means much of the complexity in a modern compiler lies in its optimization functions. C and C++ have the reputation for being able to squeeze the most out of the underlying silicon, but this reputation is built on a core of highly sophisticated analyses and transformations.

Its own worst enemy

All this complexity comes at a price. Compilers are generally perceived to be very reliable. But from our perspective, as developers of the SuperTest validation suite for C and C++ compilers, this is not the case. We have yet to encounter a compiler that passes all our tests.

Compilers are continually evolving, and with every new update there are bug fixes but also new opportunities for errors. Internally, a compiler is like a conveyor belt of many specialized processing steps. Are they modular? Absolutely yes, but an error in any one of these steps can ruin it for the rest. You simply cannot assume that a new update will be more reliable than the previous version.

So a compiler is not ‘just a translator’. It is the one essential tool that processes all of your application’s source code, even if it does it invisibly. It is relied on to report errors in your source code if there are any, and to generate super-efficient machine code if there aren’t any.

That’s why we continue to reiterate the importance of compiler testing and qualification. If your application is safety critical, or your reputation relies on delivering high-quality code, you can’t depend on the perception of compiler reliability. You need to know for sure the reliability of this central element in your tool chain.

Join our Technical Training Webinar

On June 4, Solid Sands and AFuzion will present a Technical Training Webinar on key technical aspects of safety-critical testing related to cyber-security and compilers. This free, 1-hour technical webinar will provide critical details and best practices on how to prevent software defects by addressing compiler and library quality before you develop safety-critical applications.

To register for the Webinar, please click on the button below.

Subscribe to our monthly blog!