To build code for TeleMetrum, we're using SDCC, the Small Device C Compiler as the CPU inside the cc1111 is an 8051 clone, an 8-bit microprocessor for which SDCC has excellent support (more about the flight software later).

SDCC version 2.9.0 was recently uploaded to Debian unstable, and when I built our flight software with the new version, I discovered a bug in the display of strings formatted by printf. First assuming that the bug was in my source code, I tried to figure out what I'd done wrong, but then I eventually looked that the 8051 assembly output (ick) and discovered that the compiler was generating the wrong code for pointers when passed to a varargs function. A bit of hacking and I soon had a short test case that demonstrated the bug:

extern void f(char *x, ...);

void
func(__xdata char *s)
{
    f("hi", s);
}

I filed a brief bug report and attached the test case, then went to download the current source code to see if I couldn't uncover the source of the bug. I have to say that reading through the SDCC source code was reasonably pleasant; a competent compiler in very little code that was easy to grasp. I eventually located the bug, and discovered that it was from a change made last December as part of a pointer-related optimization, and I posted a patch that I found would fix the specific problem I had found.

The nicest part came next -- once I'd posted the patch, a reasonably lively discussion between Maarten Brock, Borut Ra┼żem and Raphael Neider came to a quick concensus about what the desired behavior in this case would be.

Then, Maarten Brock applied my patch to the project and, much to my amazement, he included a regression test that verified the desired behaviour in both the case that I had uncovered and several other cases as well.

I just want to applaud these developers for building a great compiler and running a great project.