public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/36587]  New: Feature: add warning for constructor call with discarded return.
@ 2008-06-20 19:22 kkylheku at gmail dot com
  2008-06-20 19:24 ` [Bug c++/36587] " kkylheku at gmail dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 18+ messages in thread
From: kkylheku at gmail dot com @ 2008-06-20 19:22 UTC (permalink / raw)
  To: gcc-bugs

This patch implements a ``-Wunused-objects'' warning which is triggered if a
constructor is called, and the returned object is thrown away.

This can happen by accident when a declaration for an object accidentally omits
a name. For instance:

  {
    trace_class ("foo", ...);
    //         ^ missing name
  }

Whereas it is common for C++ function calls to discard returned objects,
discarding the result of an explicit constructor call is most likely a mistake.

I developed a patch against GCC 4.1.1 for this (because that's the compiler
currently used by my organization). The patch doesn't include a documentation
update, just code.


-- 
           Summary: Feature: add warning for constructor call with discarded
                    return.
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kkylheku at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36587


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2024-03-18 16:18 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-36587-4@http.gcc.gnu.org/bugzilla/>
2013-09-24 21:49 ` [Bug c++/36587] Feature: add warning for constructor call with discarded return redi at gcc dot gnu.org
2013-09-24 21:52 ` redi at gcc dot gnu.org
2015-07-23 13:51 ` manu at gcc dot gnu.org
2015-07-24 18:47 ` kkylheku at gmail dot com
2015-07-24 21:21 ` redi at gcc dot gnu.org
2015-07-24 22:29 ` manu at gcc dot gnu.org
2024-03-16 23:32 ` pinskia at gcc dot gnu.org
2024-03-18  2:44 ` kkylheku at gmail dot com
2024-03-18  2:53 ` kkylheku at gmail dot com
2024-03-18  6:50 ` redi at gcc dot gnu.org
2024-03-18  7:20 ` redi at gcc dot gnu.org
2024-03-18 16:18 ` kkylheku at gmail dot com
2008-06-20 19:22 [Bug c++/36587] New: " kkylheku at gmail dot com
2008-06-20 19:24 ` [Bug c++/36587] " kkylheku at gmail dot com
2008-06-20 20:27 ` kkylheku at gmail dot com
2009-12-11  0:37 ` redi at gcc dot gnu dot org
2009-12-11  2:34 ` kkylheku at gmail dot com
2009-12-11 10:39 ` jwakely dot gcc at gmail dot com
2009-12-11 11:58 ` kkylheku at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).