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

前端 未结 26 1169
南方客
南方客 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:27

    When a pointer is first allocated, it does not have a pointee.

    The pointer is "uninitialized"

    A dereference operation on a bad pointer is a serious runtime error.

    If you are lucky, the dereference operation will crash or halt immediately (Java behaves this way).

    If you are unlucky, the bad pointer dereference will corrupt a random area of memory, slightly altering the operation of the program so that it goes wrong some indefinite time later. Each pointer must be assigned a pointee before it can support dereference operations.

提交回复
热议问题