Member initialization list warning flag

Zygmunt Ptak zygmuntptak@gmail.com
Mon Nov 9 20:41:00 GMT 2015


Hi,

Is there any param in the gcc which will warn about not initialized
class member from the initialization list?

Example:

class A {
  A() : number(-1) {}
private:
  std::string text;
  int number;
  void* badPointer;
};

I that case there should be two warnings:
1. About not initialized text
2. About not initialized badPointer

I see a lot of problems with forgotten initialized members by the
programmers.
Having this type of warning would safe a lot of time.
If something has already "safe" ctor, then we are good, but with
pointers we can have a big problem.

Regards
Zygmunt Ptak



More information about the Gcc-help mailing list