Easy way find uninitialized member variables

后端 未结 11 959
时光说笑
时光说笑 2020-11-29 22:20

I am looking for an easy way to find uninitialized class member variables.

Finding them in either runtime or compile time is OK.

Currently

11条回答
  •  误落风尘
    2020-11-29 22:54

    -Wuninitialized ?

    (This only checks if a variable is used uninitialized, i.e. if

    struct Q { 
      int x, y;
      Q() : x(2) {}
      int get_xy() const { return x*y; }
    };
    

    g++ will warn only when the user calls get_xy() without assigning to y.)

提交回复
热议问题