This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/18272] weird behaviour on temporary return values
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 2 Nov 2004 14:14:55 -0000
- Subject: [Bug c++/18272] weird behaviour on temporary return values
- References: <20041102123746.18272.philippe.haution@mines-paris.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-11-02 14:14 -------
I think this is correct and here is why:
auto_ptr<vector<int> > res1 = ert(); // OK <-- we call the copy construtor so we increment the
refence
vector<int>& res2 = *res1; // OK <-- this is reference already
vector<int> *res3 = ert().get(); // NOK <-- we don't increment the reference so we will free it
right after this statement has been executated
vector<int>& res4 = *(ert()); // NOK if res5 not created afterwards
<---- same as above
vector<int>& res5 = *(ert().release());// OK
<--- should have caused an exeception as you are already freed it
temporary return values only last untill the statement is finished.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18272