Reply to post: Great C bug

You've seen things people wouldn't believe – so tell us your programming horrors

apepper

Great C bug

My favourite C bug was one I read about;

int TestFunc(void)

{

int *a, *b;

int c, d;

a = &c;

b = &d;

c=4;

d=2;

return *a/*b;

}

At first look, this function looks like it should return 2. However, it may not compile - the *a/*b contains /* - so the rest of the code is treated as a comment.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon