Improve insert/emplace robustness to self insertion

Paolo Carlini paolo.carlini@oracle.com
Wed Jun 29 09:35:00 GMT 2016


Hi,

On 29/06/2016 10:57, Jonathan Wakely wrote:
> On 28/06/16 21:59 +0200, François Dumont wrote:
>> +      if (_M_data_ptr(__position.base()) <= __ptr
>> +      && __ptr < _M_data_ptr(this->_M_impl._M_finish - 1))
>
> This is undefined behaviour. If the object is not contained in the
> vector then you can't compare its address to addresses within the
> vector.

Uhm, would that be true also if the code used std::less? Aren't we doing 
something like that in std::basic_string under the assumption (Nathan?) 
that it would not be the case? Or maybe I'm misreading the code 
(admittedly I didn't follow in detail the whole exchange)

Paolo.



More information about the Libstdc++ mailing list