This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: N3644 Comparing value-initialized iterators
- From: François Dumont <frs dot dumont at gmail dot com>
- To: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Mon, 25 Nov 2013 22:35:16 +0100
- Subject: Re: N3644 Comparing value-initialized iterators
- Authentication-results: sourceware.org; auth=none
- References: <CAH6eHdSVdfKnz72KK0a_-7xipcJ=F9e0iC2P=odKJm3_PhG+1A at mail dot gmail dot com> <528FC1D4 dot 1090605 at gmail dot com> <CAH6eHdQuD6LUf14CuncUfbW+DzqH1z+jGLKhX45SoTZkS8x9eQ at mail dot gmail dot com> <529265A0 dot 7080001 at gmail dot com> <CAH6eHdSx=V2JFHhedBe0b+2cvP45Mmw60_+x6oe_xW9oyusD-w at mail dot gmail dot com>
On 11/24/2013 10:01 PM, Jonathan Wakely wrote:
On 24 November 2013 20:46, François Dumont wrote:
I will spend some time on it if you don't mind.
I don't mind, but I'm not confident you'll be able to make
uninitialized memory give reliable results.
I am not confident neither but for the moment I can only see 3 choices:
1. Remove debug checks regarding those comparisons
2. Do not change anything so ignoring N3644 resolution
3. Detect uninitialized memory even if not reliable
People interesting in debug checks will surely not appreciate choice 1.
People that worked to have N3644 adopted will surely not appreciate 2. 3
looks like the most acceptable approach to me.
IMHO option 2 is the best one. It's correct for C++98, C++03 and C++11.
Ok, N3644 is for C++14 ? However there are already checks like:
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 408. Is vector<reverse_iterator<char*> > forbidden?
_GLIBCXX_DEBUG_VERIFY(!__x._M_singular()
|| __x._M_current == _Iterator(),
_M_message(__msg_copy_singular)
._M_iterator(*this, "this")
._M_iterator(__x, "other"));
According comment it looks like it is especially targetting
built-in types like pointers. But for other iterator types it looks like
an undefined behavior, we might miss invalid usage because of it, no ?
By the way, N3644 is only for == and != operators or also for
ordering ones like < ? I guess it is not for operator-, right ?
François