[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Patch: auto_ptr is frequently abused in TSVN code

From: Stefan Fuhrmann <stefanfuhrmann_at_alice-dsl.de>
Date: Thu, 27 Aug 2009 16:28:14 +0200

Dmitry <wipedout_at_yandex.ru> wrote:

> In TSVN sources std::auto_ptr is often used for controlling arrays. This
works by pure luck.
> auto_ptr destructor invokes delete but the array has been allocated with
new[]. Pairing new[] with
> delete instead of with delete[] is undefined behaviour. This works
because for primitive types VC+
> + maps new[] onto new but it might stop working with another version of
C++ compiler.

You are right. We should fix that. However, r17023 uses
a somewhat different approach.
> Fixed this in two patches.

I'm not sure your usage of std::vector<> is any more legal
than the usage of std::auto_ptr<> has been before.

Is there any guarantee that at least for the standard allocator
&v[0]+1 is equivalent to &v[1] ? In other words, does the
standard define that std::vector<> allocates a single,
contiguous block of objects with the same alignment then
new[] does?

Please keep sending patches ;)

-- Stefan^2.


To unsubscribe from this discussion, e-mail: [dev-unsubscribe_at_tortoisesvn.tigris.org].
Received on 2009-08-27 16:28:32 CEST

This is an archived mail posted to the TortoiseSVN Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.