Re: Uninitilised variable detection in C++

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi naveen,

On Mon, May 18, 2009 at 07:14:28PM +0530, naveen yadav wrote:
> Hi
> I am using GNU compiler and i enable all warnings still i do not get any
> warning.
> Is there any way to get warning for uninitilised variables in c++ .
> 
Probably you are looking for "-Weffc++". That reports for your file
warning: ‘Foo::m_nValue’ should be initialized in the member initialization list
> class Foo
> {
> private:
>   int m_nValue;
> public:
>   Foo();
>   int GetValue() { return m_bValue; }
> };
> Foo::Foo()
> {
>   // Oops, we forget to initialize m_nValue
> }
> int main()
> {
>   Foo cFoo;
>   if (cFoo.GetValue() > 0)
>       // do something
>   else
>       // do something else
> }


Axel

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux