Alex Rivera | Logout

Easy way find uninitialized member variables

Asked 2010-01-20T07:29:00.563
56

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

Finding them in either runtime or compile time is OK.

Currently I have a breakpoint in the class constructor and examine the member variables one by one.

Edit
Report

2 Answers

8

-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.)

answered 2010-01-20T07:35:34.653
2

/analyze on Visual Studio ("Team System")

answered 2010-01-20T15:30:51.300

Your Answer