[RFC] libstdc++-14528: auto_ptr issue (not a bug?)

Dhruv Matani dhruvbird@gmx.net
Fri Mar 12 11:11:00 GMT 2004


On Fri, 2004-03-12 at 15:48, Paolo Carlini wrote:
> Hi,
> 
> Volker nicely distilled this snippet, that current g++ doesn't
> compile:
> 
> ==========
> #include<memory>
> 
> typedef const std::auto_ptr<int> A;
> 
> void foo(const A&);
> 
> A makeA();
> 
> void bar()
> {
>     A a; foo(a);  // OK
>     foo(A());     // error
>     foo(makeA()); // error - the same as in line 45994 of the original 
> example
> }
> ===========
> 
> and also added: "The problem is, that you need a copy for the temporary
> (which can be eliminated, but in theory you need it)."
> 
> Now I'm re-reading Josuttis, in particular p. 42-44, about const auto_ptr
> meant to avoid any unintended transfer of ownership, and coming to the
> conclusion that this PR is not-a-bug, strictly speaking.
> 
> What do you think?

I think you should have a look at this message on c.std.c++ posted by
Rani Sharoni, who discusses the implementation of a better auto_ptr<>.
Maybe the problem on hand has something to do with this.

http://groups.google.co.in/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&safe=off&threadm=pan.2003.12.24.19.24.17.891215%40gmx.net&rnum=4&prev=/groups%3Fq%3Dauto_ptr%2Bgroup:comp.std.c%252B%252B%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26group%3Dcomp.std.c%252B%252B%26safe%3Doff%26scoring%3Dd%26selm%3Dpan.2003.12.24.19.24.17.891215%2540gmx.net%26rnum%3D4

(ps. I need to learn how to use tinyurl!)




-- 
	-Dhruv Matani.
http://www.geocities.com/dhruvbird/

Proud to be a Vegetarian.
http://www.vegetarianstarterkit.com/
http://www.vegkids.com/vegkids/index.html



More information about the Libstdc++ mailing list