This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/36587] New: Feature: add warning for constructor call with discarded return.
- From: "kkylheku at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Jun 2008 19:21:51 -0000
- Subject: [Bug c++/36587] New: Feature: add warning for constructor call with discarded return.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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