This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Effective c++ member initialization list spurious warning?


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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]