Self move assignment debug check
Mon Nov 2 20:42:00 GMT 2015
On 16/09/2015 22:29, Jonathan Wakely wrote:
> On 16/09/15 21:37 +0200, FranÃ§ois Dumont wrote:
>> On 14/09/2015 21:50, Jonathan Wakely wrote:
>>> On 14/09/15 20:27 +0200, FranÃ§ois Dumont wrote:
>>>> diff --git a/libstdc++-v3/include/bits/stl_vector.h
>>>> index 305d446..89a9aec 100644
>>>> --- a/libstdc++-v3/include/bits/stl_vector.h
>>>> +++ b/libstdc++-v3/include/bits/stl_vector.h
>>>> @@ -449,6 +449,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
>>>> operator=(vector&& __x)
>>>> + __glibcxx_assert(this != &__x);
>>> Please don't do this, it fails in valid programs. The standard needs
>>> to be fixed in this regard.
>> The debug mode check should be removed too then.
I had a look to the code of several move assignment operators. If
the plan is that it should be a no-op then they are not supporting
operation with self. Do you mean that those operators should be made
compatible so that debug check can be removed ?
If so the simplest evolution would be to add:
if (this == &__x)
Is it how the Standard is going to be adapted ?
More information about the Libstdc++