EW EST. 2022
The Compiler Said Yes THE ARCHIVE
Accessibility

Reading preferences

← BACK TO THE ARCHIVE

SOFTWARE ENGINEERING

The Compiler Said Yes

Compiler messages and their cryptic, occasionally amusing clues—and how learning to interpret them makes debugging a little less mysterious.

BY ETHAN WILSON /

There is a particular satisfaction in watching a program compile after spending time trying to understand why it would not. The errors disappear, the build finishes, and for a moment, it feels like everything has fallen into place.

Then you run it.

The result might be correct. It might also be completely unexpected. A calculation produces the wrong number, a loop skips something it should have included, or the program confidently does something you never intended.

The compiler said yes. Apparently, I had asked the wrong question. The oversized “T” opening this article is doing its best to make itself impossible to miss. Bugs rarely extend the same courtesy. A single character can change a program’s behavior without attracting much attention—and sometimes without a complaint from the compiler.

The Compiler Wants To Speak To The Manager

Starting with C++ meant learning to read code and compiler messages at the same time. Neither was especially familiar. An error could identify a line, name the offense, and STILL leave me wondering what I had done. Basically, the compiler wanted to speak to the manager. Unfortunately, the manager was also the trainee, and his training consisted largely of investigating the incident he had just caused. I was responsible for the program’s decisions while still learning how to make them—simultaneously heading the inquiry and appearing as its principal suspect. There was nobody higher up to escalate the complaint to, so I held a brief meeting with myself. Management requested answers. The trainee requested an example. Both agreed to look up what “undeclared identifier” meant.

Sometimes the message is straightforward: a name has not been declared, or a statement needs a semicolon. Other times, the compiler reports a problem farther down than the mistake that caused it. A missing brace can change how it interprets everything that follows, leaving what looks like a collection of separate problems. Apparently, even punctuation can have an entourage. Now your gobsmacked.

That can make a small mistake look impressively destructive.

I am learning to begin with the first reported error and inspect the surrounding code, including the lines before it. Fixing one cause can clear several messages. Trying to solve every message independently can mean chasing problems that disappear as soon as the original mistake is corrected. Before convening a full inquiry, it helps to check whether someone left a brace open. And by someone I mean no one else other than me.

The wording also becomes more useful as the concepts become clearer. A complaint about incompatible types carries more information once I understand which values I am working with and what an operation expects. What initially looks like an accusation gradually becomes a clue. I disect the correspondence and try my best not to take it personally.

The compiler does not always explain things in the way I would prefer, but it usually has a reason for objecting.

From the library of Ethan Wilson
Handwritten artwork on a wall