Annoying bug: escaped newline in C comment

24 10 2009

What’s wrong with this code?

// case 3\
x->parent->color = BLACK;
x->parent->parent->color = RED;

It ended up causing an infinite loop, and taking me quite a while to figure out why, thinking something was wrong with the tree rotation or logic in the cases. It turns out, I made a type at the end of the comment “// case 3\”, which escaped the newline character even inside the comment, and commented out the next line.

The rightRotate function was broken too, but that’s another story… tree rotations when you have to keep track of parent nodes and worry about 5 possible pointers being NULL isn’t fun.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: