This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/54379] New: Suggestion for type attribute similar to warn_unused_result
- From: "jewillco at osl dot iu.edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 26 Aug 2012 23:13:29 +0000
- Subject: [Bug c++/54379] New: Suggestion for type attribute similar to warn_unused_result
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54379
Bug #: 54379
Summary: Suggestion for type attribute similar to
warn_unused_result
Classification: Unclassified
Product: gcc
Version: 4.7.1
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: jewillco@osl.iu.edu
I think it would be useful to extend GCC with an attribute similar to
`warn_unused_result` but applying to a user-defined type rather than just a
single function. The effect would be that all expressions (variable
references, function calls, etc.) that return some object of that type would
warn if their results were unused. The intended use case is for C++ patterns
such as expression templates in which purely-functional code builds up an
expression tree which does not make sense to discard; in some cases, operator=
would just add to the expression tree as well, leading to a source of bugs.
This would probably require the kind of cast-to-void override mechanism that PR
25509 is about, since these annotations would strictly be recommendations.