This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/54047] unused variable warning not for std::string
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 20 Jul 2012 12:09:01 +0000
- Subject: [Bug c++/54047] unused variable warning not for std::string
- Auto-submitted: auto-generated
- References: <bug-54047-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54047
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-07-20 12:09:01 UTC ---
It's the case for all objects with a non-trivial constructor, not only
std::string.
Constructors might have side-effects, so you might not need to "use" the
variable, all you want is to construct it.
e.g. you don't want an unused variable warning for 'l' here:
void f(std::mutex& m, int& i) {
std::lock_guard<std::mutex> l(m);
i = 1;
}
I think this behaviour is intentional and correct.