3 ms·
I have one! My memory is pretty crap, and I've been around the block a few times so I'm not stating that this truly is my worst bug but it was ... bad. I was
by unwind 4y ago
I have one!
My memory is pretty crap, and I've been around the block a few times so I'm not stating that this truly is my worst bug but it was ... bad.
I was working in embedded, developing part of the control software for ... something. The microcontroller had a vendor-developed C compiler, with some extensions. It was a 16-bit chip more or less, so addressing large areas of memory was complicated. The flash was larger than 64 KB, so in order to write all of it you had to use more than 16 bits.
Luckily, the vendor compiler had an extension like in the DOS days, where you could add the proprietary "far" modifier to a pointer in order to signal that you wanted lots of range. Like this:
unsigned char far *ptr = FLASH_BASE;
or something. Imagine then my surprise when I was looping over the flash (I think I was computing a CRC to validate software integrity, or something) and
ptr++;
simply failed to reach all of it. I read the generated code, and the compiler was emitting 16-bit arithmetic, completely ignoring the fantastic "far" modifier. I changed it to something like
ptr = (unsigned char *) ((uint32_t) ptr + 1);
and got the proper code, and it worked.
At that point, I was like "whoa, I found a compiler bug, gonna report it!" and sent off the details to our field applications engineer from the vendor.
...
Who came back with "yeah, we know, but we choose this behavior since it gives better performance" or something along those lines.
That just completely killed my trust in that vendor, and any interest in working with them again. As a person who has been writing code for close to 40 years, that kind of attitude just blows my mind, and really makes me upset. You're supposed to trust the compiler, a compiler bug should be rare. Correctness is important, these here programming things are hard enough without having the compiler lie to you.
Gosh, it makes me upset even now just thinking about it. Heh.
*Goes back to hugging open source compilers.*