auto_ptr behaviour

View: New views
3 Messages — Rating Filter:   Alert me  

auto_ptr behaviour

by Muller :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi, team!

It seems like auto_ptr takes its constructor argument assuming it a
auto_ptr_ref (argument is a raw pointer in fact). VC71 compiler produces an
error. The workaround found so far (to calm down the compiler) is simply
commenting the troublesome constructor or modifying its argument with a
reference sign.
Would be nice to have a proper solution instead of such hacks.

Thanks,
Sergey Melnikov.

Re: auto_ptr behaviour

by Martin Sebor :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Muller wrote:
> Hi, team!
>
> It seems like auto_ptr takes its constructor argument assuming it a
> auto_ptr_ref (argument is a raw pointer in fact).

The standard requires implementations to provide the three auto_ptr
ctors below. AFAICS, those are exactly the ones we define:

     explicit auto_ptr(X* p =0) throw();
     auto_ptr(auto_ptr&) throw();
     template<class Y> auto_ptr(auto_ptr<Y>&) throw();

> VC71 compiler produces an
> error. The workaround found so far (to calm down the compiler) is simply
> commenting the troublesome constructor or modifying its argument with a
> reference sign.

We'd need to see a test case to determine whether we're dealing
with a bug in stdcxx, the compiler, or perhaps even your code :)
Auto_ptr is a tricky beast and some compilers have trouble with
it. From our nightly test results it looks like MSVC 7.1 might
be one of them since it fails to compile the 20.auto.ptr.cpp
test:
http://people.apache.org/~sebor/stdcxx/results/Windows_2000-msvc-7.1-11s-log.gz.txt
http://svn.apache.org/repos/asf/incubator/stdcxx/trunk/tests/utilities/20.auto.ptr.cpp

MSVC 8.0, OTOH, compiles and runs 20.auto.ptr.cpp just fine:
http://people.apache.org/~sebor/stdcxx/results/windows-2003-msvc-32b-8.0-15s-log.gz.txt

That said, if this usage is important to you I suggest you open
a bug report in Jira (and include a test case). We might be able
to come up with a workaround for MSVC 7.1.

Martin


Parent Message unknown Re: auto_ptr behaviour

by Muller :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Martin,

I receive the same C2440 with auto_ptr as in your nightly build log and it
is a stopper. I'll look through the source code and try to provide you with
the proper test case (with all the STL's containers, iterators and
algorithms involved).

Thanks,
Sergey Melnikov.