gcc /g++ Why some variables are not detected as not used during compilation?
Sunday 12 June 2011, by
In the following example, variable x is not detected as not used
std::vector< double > x;
g++ -Wall test.cpp
test.cpp: In function 'int main()':
test.cpp:6:6: warning: unused variable 'k'
test.cpp:6:8: warning: unused variable 'l'
Actually, warnings are only declared for built in types (bool, int, float, double, etc ...). Compiler can’t determine if removing declaration of x would change the behaviour of semantics program.