This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/54379] New: Suggestion for type attribute similar to warn_unused_result


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]