Is using an invalid pointer value legal in C?

后端 未结 3 760
长发绾君心
长发绾君心 2021-01-14 19:59

The following code is undefined behavior in C++ (although it will work okay on almost any widely used implementation):

int* pointer; //uninitialized - likely         


        
3条回答
  •  醉梦人生
    2021-01-14 20:49

    It is undefined behavior in C99. The value of pointer is "indeterminate" (6.7.8.10) and an indeterminate value can be a trap value that causes undefinedness when used.

提交回复
热议问题