Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-04-10 16:08:31


From: "Gary Powell" <Gary.Powell_at_[hidden]>

> >>
> When I comment the #if/#endif lines it compiles but crashes when run. :-)
> <<
> Hmm..
> "Runs with my compilers!" :>
> No seriously, can you run the debugger and see what the problem is?

In a debug build the memory manager yells at me at auto_ptr<X[]>::~auto_ptr,
in delete[] this->get(), when I continue I get an access violation. Weird.

The line that triggers it is

  auto_ptr<B[]> b3(array_source_b());

so it must be the destructor of the temporary.

array_source_b() by itself works, array_sink_b(array_source_b()) doesn't.

Ah, yes, I see it now. You have the same #if/#endif pair there, too, so you
don't define a copy constructor and the compiler happily generates a
default.

> > I wonder what copy constructor does MSVC use. :-)
>
> I think it uses
> template<typename Y>
> auto_ptr(auto_ptr<Y> &rhs);
>
> because if I undef the BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP for MSVC I get
> errors about multiple definitions of
> auto_ptr(auto_ptr &rhs);

You do know that for MSVC 6 the non-template must come _after_ the template
as it's considered a specialization by the compiler, don't you? :-) [MSVC 7
seems to handle this as-is, without the #if.]

And what's this to do with the argument-dependent lookup?

--
Peter Dimov
Multi Media Ltd.

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk