Effective c++ member initialization list spurious warning?

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

 



Using:

~/beta/bin/g++ -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../configure --prefix=/home/$HOME/beta
--with-gmp=/home/$HOME/beta --with-mpfr=/home/$HOME/beta
Thread model: posix
gcc version 4.3.0 20071104 (experimental) (GCC)


With the following:

#include <iostream>
#include <sstream>

class t
{
   std::ostringstream msg;
public:
   t(){};
};


int main()
{
   std::ostringstream m;
   std::cout << "[" << m.str() << "]" << std::endl;
}


The following warning is generated.

$ ~/beta/bin/g++ -Wall -Weffc++ test.c
test.c: In constructor at::t():
test.c:9: warning: t::msg should be initialized in the member
initialization list


$ ./a.out
[]


Given that msg is guaranteed to be initialized is this warning
absolutely necessary?

Regards,

JT

[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