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

Paolo Carlini pcarlini@suse.de
Fri Mar 12 10:18:00 GMT 2004


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?

Paolo.



More information about the Libstdc++ mailing list