Reply to post: Reminds me of a compiler bug I encountered

I'm not Boeing anywhere near that: Coder whizz heads off jumbo-sized maintenance snafu

Michael H.F. Wilkinson Silver badge

Reminds me of a compiler bug I encountered

From 1988 until 1995 I was in charge of developing an image processing system for a microscopy system, in a mixture of MS-Pascal (the previous programmer shunned C), and MS-C. The choice of MS compilers was foisted upon us by the fact that the Matrox MVP-AT/NP and PIP-1024 boards we were using only came with an MS-C compatible library. I recall a situation where I was baffled by crashes caused by a piece of code I had just written, and I couldn't for the life of me see any fault in the (very simple, just 20 LOC) procedure at the heart of the problem. As input it took a linked list which had an even number of nodes, so if you started with the current pointer pointing at the head of the list, you should be able to write

IF current^.next <> NIL THEN current:= current^.next^.next;

to move down the list in strides of two. Result: CRASH. I checked whether the input was wrong, by counting the number of nodes, but nothing was wrong. I then changed the code to:

IF current^.next <> NIL THEN

BEGIN

current:= current^.next;

current:=current^.next;

END;

and that worked flawlessly. I am not sure if this was an optimizer bug, or a bug in the parser, but I did feel an urge to jettison the compiler manual out of the second-floor window.

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