------- Additional Comments From philippe dot haution at mines-paris dot org 2004-11-02 14:54 ------- You wrote about reference incrementing, but as far as auto_ptrs are concerned, there's only ownership transfer of the underlying pointer.
res1 and res2 are OK, no problem about that. But res5 = *(ert().release()); should and did not cause any exception because this code is absolutely correct. Each call to the ert() function allocates a new vector wrapped in a new temporary auto_ptr, so you can perform as many ert().release() as you like and I am afraid I don't agree at all with your comment about this line. My initial concern was about : vector<int> *res3 = ert().get(); vector<int>& res4 = *(ert()); After those two lines, it looks like res3 and res4 have lost the expected result. If "temporary return values only last until the statement is finished", then it's incorrect code and gcc's behaviour is OK. Then why do those 2 variables res3 and res4 hold the right result if I just add the instruction about res5 ? Try to execute the program with and without this instruction and see. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18272