This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: [Bug libstdc++/15523] New: Can't have vectors of vector::const_iterator
- From: llewelly at xmission dot com
- To: gcc-bugzilla at gcc dot gnu dot org
- Cc: gcc-bugs at gcc dot gnu dot org
- Date: 18 May 2004 23:11:05 -0600
- Subject: Re: [Bug libstdc++/15523] New: Can't have vectors of vector::const_iterator
- References: <20040518193757.15523.bangerth@dealii.org>
"bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> writes:
> I definitely like the debug mode in libstdc++, but happened to fall over this:
> -----------------
> #include <vector>
>
> int main ()
> {
> std::vector<std::vector<int>::const_iterator> x(2);
> }
> -----------------
>
> When compiled with -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC, I got this:
>
> homes/csm2/bangerth/bin/gcc-3.4.0/bin/../lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/debug/safe_iterator.h:125:
> error: attempt to copy-construct an iterator from a singular iterator.
>
> Objects involved in the operation:
> iterator "this" @ 0x0x8067ee0 {
> type =
> N11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIPKiN10__gnu_norm6vectorIiSaIiEEEEEN15__gnu_debug_def6vectorIiS7_EEEE
> (constant iterator);
> state = singular;
> }
> iterator "other" @ 0x0xbfffdd40 {
> type =
> N11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIPKiN10__gnu_norm6vectorIiSaIiEEEEEN15__gnu_debug_def6vectorIiS7_EEEE
> (constant iterator);
> state = singular;
> }
>
>
> For some reason, I fail to see why I shouldn't be allowed to copy-construct from an
> invalid iterator. After all, the result would still be invalid and
> couldn't be dereferenced, no?
Copying an invalid iterator is undefined behavior. 24.1/5 .
> I think this should be allowed.
Is there a gcc target where (a) loading an invalid address into an
address register causes a hardware fault, and (b) copy
constructing an invalid iterator might require such a load?