This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Improve insert/emplace robustness to self insertion


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]