This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/36587] 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: 11 Dec 2009 11:57:58 -0000
- Subject: [Bug c++/36587] Feature: add warning for constructor call with discarded return.
- References: <bug-36587-15518@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #6 from kkylheku at gmail dot com 2009-12-11 11:57 -------
(In reply to comment #5)
> (In reply to comment #4)
> > > But I'm not convinced that doing this is always a mistake.
> >
> > Since we don't care about the object, we must care about the constructor side
> > effect. I seem to be under the impression that ISO C++ allows the construction
> > of temporary objects to be optimized away---even if there are side effects in
> > the constructor or destructor! Therefore, it's hard to see a valid use case for
> > this.
> Certain temporaries (such as those created during copying or reference binding)
> can be optimised away, I don't think it's true of temporaries created
> explicitly like this.
I've gone over the relevant 14882:2003 sections and have come to the same
conclusion.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36587