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++/18272] weird behaviour on temporary return values


------- 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


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