Well, interestingly enough, I can't get it to complain about an initializer list either. If I use -Wunused, I do get two warnings about unused parameter enable, though.
OOH Update: The above was true on my gcc 3.4.5 in MinGW. Using gcc 4something on the Mac, I get this:
Code:
$ g++ -Wunused -Wuninitialized -O1 -Winit-self -o warns warns.cpp
warns.cpp: In function ‘int main()’:
warns.cpp:12: warning: ‘baz$enabled’ is used uninitialized in this function
warns.cpp:12: warning: ‘bar$enabled’ is used uninitialized in this function
So I lost the unused warning, but gained uninitialized warnings. Apparently how the optimizations go is important.
(For the curious, the code:
Code:
include <iostream>
struct foo {
bool enabled;
foo( bool enable ) :
enabled(enabled)
{ }
};
int main() {
foo bar(true), baz(false);
std::cout << bar.enabled << " " << baz.enabled << std::endl;
return 0;
}