[Bug libstdc++/60587] New: debug-mode -std=c++11 vector::insert(pos, begin, end) dereferences begin too eagerly
sbergman at redhat dot com
gcc-bugzilla@gcc.gnu.org
Wed Mar 19 14:09:00 GMT 2014
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60587
Bug ID: 60587
Summary: debug-mode -std=c++11 vector::insert(pos, begin, end)
dereferences begin too eagerly
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: sbergman at redhat dot com
At least on recent trunk (r208675),
> $ cat test.cc
> #define _GLIBCXX_DEBUG
> #include <vector>
> int main() {
> std::vector<int> a, b;
> a.push_back(1);
> a.insert(a.end(), b.begin(), b.end());
> }
> $ ~/gcc/trunk/inst/g++ -std=c++11 test.cc
> $ ./a.out
> ~/gcc/trunk/inst/include/c++/4.9.0/debug/safe_iterator.h:261:
> error: attempt to dereference a past-the-end iterator.
>
> Objects involved in the operation:
> iterator "this" @ 0x0x7fff0d764060 {
> type = N11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIPiNSt9__cxx19986vectorIiSaIiEEEEENSt7__debug6vectorIiS6_EEEE (mutable iterator);
> state = past-the-end;
> references sequence with type `NSt7__debug6vectorIiSaIiEEE' @ 0x0x7fff0d764be0
> }
which
> Index: libstdc++-v3/include/debug/macros.h
> ===================================================================
> --- libstdc++-v3/include/debug/macros.h (revision 208675)
> +++ libstdc++-v3/include/debug/macros.h (working copy)
> @@ -106,7 +106,7 @@
> #define __glibcxx_check_insert_range(_Position,_First,_Last) \
> __glibcxx_check_valid_range(_First,_Last); \
> __glibcxx_check_insert(_Position); \
> -_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__foreign_iterator(_Position,_First),\
> +_GLIBCXX_DEBUG_VERIFY(_First==_Last||__gnu_debug::__foreign_iterator(_Position,_First),\
> _M_message(__gnu_debug::__msg_insert_range_from_self)\
> ._M_iterator(_First, #_First) \
> ._M_iterator(_Last, #_Last) \
works around for me.
More information about the Gcc-bugs
mailing list