What is the meaning of “wild pointer” in C?

前端 未结 11 1671
终归单人心
终归单人心 2020-11-30 04:14

Can anybody tell me, the meaning of wild pointer in C, how to obtain it and is this available in C++?

11条回答
  •  甜味超标
    2020-11-30 04:36

    A wild pointer in C is a pointer that has not been initialised prior to its first use. From Wikipedia:

    Wild pointers are created by omitting necessary initialization prior to first use. Thus, strictly speaking, every pointer in programming languages which do not enforce initialization begins as a wild pointer.

    This most often occurs due to jumping over the initialization, not by omitting it. Most compilers are able to warn about this.

    eg

    int f(int i)
    {
        char* dp;    //dp is a wild pointer
        ...
    }
    

提交回复
热议问题