piotr
piotr

Reputation: 5787

Make g++ warn on uninitialized POD member variable

Is there a way to print a warning if you forget to declare in ctor initialization list a member POD? I'm looking through docs and can't find anything. g++-4.4 here.

Upvotes: 7

Views: 1034

Answers (2)

Alok Save
Alok Save

Reputation: 206546

You can use the option -Wuninitialized (and also -Wall).
However, It only warns if the Uninitialized type is being used.

Also, Ofcourse you can use other softwares like Valgrind and Cppcheck to determine Uninitialized types.

Upvotes: 3

Kerrek SB
Kerrek SB

Reputation: 477140

You can enable -Weffc++ to get a heap of ridiculous warnings, including every single non-ctor-initialized member.

To check for actual UB, use valgrind.

Upvotes: 5

Related Questions