UnThreaded | Threaded | Whole Thread (11) | Ignore Thread Prev | Next
Author: crassfool Big funky green star, 20000 posts Feste Award Nominee! Old School Fool Add to my Favorite Fools Ignore this person (you won't see their posts anymore) Number: of 1648  
Subject: Rare bird Date: 12/11/2011 1:27 AM
Post New | Post Reply | Reply Later | Create Poll Report this Post | Recommend it!
Recommendations: 0
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.
Post New | Post Reply | Reply Later | Create Poll Report this Post | Recommend it!
Print the post  
UnThreaded | Threaded | Whole Thread (11) | Ignore Thread Prev | Next

Announcements

Foolanthropy 2014!
By working with young, first-time moms, Nurse-Family Partnership is able to truly change lives – for generations to come.
When Life Gives You Lemons
We all have had hardships and made poor decisions. The important thing is how we respond and grow. Read the story of a Fool who started from nothing, and looks to gain everything.
Post of the Day:
Macro Economics

Looking at Currency Ratios
What was Your Dumbest Investment?
Share it with us -- and learn from others' stories of flubs.
Community Home
Speak Your Mind, Start Your Blog, Rate Your Stocks

Community Team Fools - who are those TMF's?
Contact Us
Contact Customer Service and other Fool departments here.
Work for Fools?
Winner of the Washingtonian great places to work, and "#1 Media Company to Work For" (BusinessInsider 2011)! Have access to all of TMF's online and email products for FREE, and be paid for your contributions to TMF! Click the link and start your Fool career.
Advertisement