[Bug c++/54379] New: Suggestion for type attribute similar to warn_unused_result
jewillco at osl dot iu.edu
gcc-bugzilla@gcc.gnu.org
Sun Aug 26 23:13:00 GMT 2012
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.
More information about the Gcc-bugs
mailing list