debug vector move issue

Jonathan Wakely jwakely.gcc@gmail.com
Thu Sep 16 12:42:00 GMT 2010


Hi François, thanks for your contributions to the debug mode.  I told
Paolo I would help to review them, as I'm familiar with a lot of the
debug mode, but I've been too follow your work in detail.  I'll try to
change that.


On 15 September 2010 21:23, François Dumont wrote:
> Hi
>
>    While working on debug forward_list I noticed that all debug containers
> were missing move constructor and move assignment operator from normal
> container. I started adding those and will submit a patch for that however
> there is a problem on vector. Attached is a test I wrote for this container.
>
> When compiled with the necessary attached patch on debug vector it works
> fine. However when you define _GLIBCXX_DEBUG_PEDANTIC the test a.capacity()
> == r.capacity() fails. This is because when you create a normal vector by
> moving a debug one internal memory is transferred but the debug vector
> _M_guaranteed_capacity is not reseted. This result in the test by the moved
> debug vector instance 'a' announcing a capacity of 1 when in fact it is 0.
>
> I see no real good solution to this problem, _M_guarantied_capacity seemed
> to be impossible to maintain when the debug container is moved. Maybe
> putting this data in the allocator could help, I need to investigate.
>
> Any thoughts ?

(I haven't looked in detail or refreshed my memory of how the debug
vector works, I've only looked at your attachments)

Can't the move constructor and move assignment set
__x._M_guaranteed_capacity = 0 ?

As Paolo said, the test seems invalid to me, it's trying to verify
something which is not guaranteed (and in general cannot be.)

Apologies if my cursory glance has meant I missed something!

Jonathan



More information about the Libstdc++ mailing list