This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Effective c++ member initialization list spurious warning?
- From: "James Tebneff" <tebneff at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Mon, 5 Nov 2007 10:35:26 +1030
- Subject: 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