[Bug c++/55203] No unused warning for variables of non-trivial types
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55203 --- Comment #5 from Lubos Lunak l.lunak at suse dot cz --- Gcc patch is in, r200941. Keeping open for libstdc++ to use the attribute for its relevant classes. I can try to submit a patch when I find the time, but I doubt I'll get past the most obvious classes, so anyone more knowledgeable about libstdc++ can feel free.
[Bug c++/55203] No unused warning for variables of non-trivial types
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55203 --- Comment #8 from Lubos Lunak l.lunak at suse dot cz --- (In reply to Jonathan Wakely from comment #6) Which are the relevant classes? It seems to me that we want to tag almost everything except a few RAII types such as std::lock_guard and std::unique_lock, which would be quite tedious. It's certainly applicable on all containers, and most streams except fstreams (which have constructors with side-effects.) Correct. And I do not see a better way than tagging everything where it applies. I think your extend.texi change is wrong, a std::mutex that is unused is useless, its constructor and destructor don't do anything useful. A std::lock_guard that is unused is *not* useless. Correct as well. But that doesn't come from my patch, that section was altered by Jason Merrill before committing, and I overlooked that. Can you fix that easily or should I submit a patch?
[Bug c++/55203] New: No unused warning for variables of non-trivial types
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55203 Bug #: 55203 Summary: No unused warning for variables of non-trivial types Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: l.lu...@suse.cz GCC warns about unused variables e.g. of type 'int', but not 'std::string' : $ cat a.cpp #include string void foo() { int i; std::string s; } $ g++ -Wall -Wunused -c a.cpp a.cpp: In function ‘void foo()’: a.cpp:5:9: warning: unused variable ‘i’ [-Wunused-variable] int i; ^ In the function 's' is apparently unused too, but the compiler cannot tell it.
[Bug c++/55203] No unused warning for variables of non-trivial types
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55203 Lubos Lunak l.lunak at suse dot cz changed: What|Removed |Added Severity|normal |enhancement --- Comment #1 from Lubos Lunak l.lunak at suse dot cz 2012-11-04 11:04:01 UTC --- As the compiler cannot tell for sure in some cases, such as the ctor calling an external function, the only reasonable way of handling this I see is explicit tagging of types for which there should be an unused warning if only ctor/dtor are called for a variable. Here's my attempt at attribute warn_unused.
[Bug c++/55203] No unused warning for variables of non-trivial types
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55203 --- Comment #2 from Lubos Lunak l.lunak at suse dot cz 2012-11-04 11:04:52 UTC --- Created attachment 28609 -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=28609 gcc patch