[patch] fix docs for C++ warn_unused type attribute

Jonathan Wakely jwakely@redhat.com
Wed Feb 17 14:49:00 GMT 2016

https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Attributes.html says
that attribute((warn_unused)) is not useful for std::mutex because it
controls a resource. That's incorrect, std::mutex *is* a resource, but
it doesn't control one. In fact declaring std::mutex as a local
variable and then never using it almost certainly is a mistake,
because it won't be locked unless you use it.

A better example of a type that controls a resource would be
std::lock_guard, which you would typically construct and then never
refer to again (because everything interesting happens in the
constructor and destructor).

OK for trunk?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 757 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20160217/0e797916/attachment.bin>

More information about the Gcc-patches mailing list