Over the last few days I have been dealing with a very mysterious bug that showed up in a product I just shipped. After a lot of detective work, and some help from a very smart colleague and friend, it became clear that it's that very rare bird, a bona fide compiler bug.You likely know how it is. You get a bug that you can't understand, that makes no sense at all, where the computer goes all haywire when your code is simple, straightforward, and everyone who looks at it says it's right. Might be a compiler bug, right? But if you come right out and call it that, somebody will immediately prove that it's not, it's an error on your part, and you're humiliated.But this one, hey, this IS a compiler bug. You've got a standard type representing a "size" -- width and height of a rectangle. It's just a C struct containing two floats. BUT if you access the height member with someSize.height, you don't get the height. You get the width! It drove me nuts until my pal realized that was happening. If you access the width with someSize.width, it works fine. And if you assign a value to the height with someSize.height = aValue, that works fine too. It's only when you take the value of the height that something goes wrong.I worked around it by taking the address of someSize, then using pointer arithmetic to get the height member of the struct. That was completely successful.But what IS the compiler bug? There are other standard structs containing two floats, such as a type representing a point, with two floats for X and Y. No bug there. Just this one "size of a rectangle" type.So I'm guessing that someone decided to put an optimization in the compiler just for this specific type, and got it wrong. And then they fixed it, but they forgot a corner scenario like mine: code that is compiled to run on several different versions of the OS works fine on most of them, but fails in one scenario: code compiled with a "final build" configuration, running on a system with an old OS. And my customer base uses a lot of old hardware that only supports old versions of the OS.OOOh, I'm gonna file such a bug report.
Best Of |
Favorites & Replies |
Start a New Board |
My Fool |
BATS data provided in real-time. NYSE, NASDAQ and NYSEMKT data delayed 15 minutes.
Real-Time prices provided by BATS. Market data provided by Interactive Data.
Company fundamental data provided by Morningstar. Earnings Estimates