D Haley writes: Ah, perhaps a distant cousin. Hi! > I came across this situation recently > > Consider the following code > > #include <sstream> > > using std::stringstream; > > int main() > { > int i; > stringstream ss; > } > > I the compiled it with > > gcc main.cpp -Wall -lstdc++ > >main.cpp: In function 'int main()': > >main.cpp:7: warning: unused variable 'i' > > Why did this not warn me about the unused stringstream? > Can wall only catch unused primitive types? No, it's not that, it's ... > Is it because the constructor is called and therefore it is not unused? Yes. > It seems that -Wall should pick this up from the point of view of "i > declared it then did nothing, this is incorrect" (also i used no params > in the constructor), but it is concievable that declaring this object > might be sufficient for some action to be taken by the code, thus > rendering it incorrect for -Wall to report it. You got it in one. For example, you might see { lock myLock; ... } where the lock constructor locks memory and the destructor releases it. > Is this desirable behaviour by GCC or not? Sure is. Andrew.