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]

Re: No warning on unused variable



> > Why did this not warn me about the unused stringstream?
[snip]
> 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.
It might be nice if g++ could add an __attribute__ setting so you could tag a class with something like ctor_has_no_useful_side_effects. Classes with this attribute could then be allowed to raise the "declared but not used" warning. It would be most useful on things like std::string, which you also wouldn't want just laying around.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]