What was the most dangerous programming mistake you have made in C?

前端 未结 26 1708
南方客
南方客 2021-02-03 12:46

I am an intermediate C programmer. If you have made any coding mistake that you came to know later that it was the most hazardous / harmful to the total application please share

26条回答
  •  感动是毒
    2021-02-03 13:18

    Having been a Lisp programmer, I was used to indenting closing braces, as in:

    (cond
        ((eq a foo)(bar ...
            ....
            ))
        )
    

    and I carried this into C programming:

    if (a == foo){
        bar(...);
        ....
        }
    

    Then I got on a good-size project in C, and another programmer had to make changes in the vicinity of my code. He mis-read my closing brackets, and freed some memory too early. This caused an extremely subtle bug that happened at crunch time. When it was found, he got blamed, badly. But you could say it was my fault. That was not fun, to say the least.

提交回复
热议问题