#include <vector> std::vector<int>::const_iterator find_arc() { std::vector<int> v; std::vector<int>::const_iterator it = v.begin(); std::vector<int>::const_iterator end = v.end(); return it == end ? v.end() : it; } g++ -D_GLIBCXX_DEBUG -c debug-mode-1.cpp debug-mode-1.cpp: In function `__gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<const int*, __gnu_norm::vector<int, std::allocator<int> > >, __gnu_debug_def::vector<int, std::allocator<int> > > find_arc()': debug-mode-1.cpp:10: error: operands to ?: have different types the type are vector<int>::iterator and vector<int>::const_iterator but a conversion should occur imho. regards, Phil
Well this has never worked from 3.0.4 to 3.5.0, even without Debug mode on or off (even though it was added just for 3.4.0). Note for some reason 2.95.3 worked but I do not know if this is really a bug. Also note ICC 6.0 accepted the code.
ok sorry too many simplification to the test case: this one work for 2.95.3/3.2.3/3.3.3 and tree-ssa, it fails only with tree ssa and -D_GLIBCXX_DEBUG #include <map> typedef std::map<int, int> container; container::const_iterator find_arc() { container v; container::const_iterator it = v.begin(); container::const_iterator end = v.end(); return it == end ? v.end() : it; }
Ok, I can confirm that one.
Subject: Bug 14340 CVSROOT: /cvs/gcc Module name: gcc Changes by: bkoz@gcc.gnu.org 2004-05-18 03:27:57 Modified files: libstdc++-v3 : ChangeLog libstdc++-v3/include/debug: safe_iterator.h libstdc++-v3/testsuite: testsuite_hooks.h Added files: libstdc++-v3/testsuite/23_containers/deque: 14340.cc libstdc++-v3/testsuite/23_containers/list: 14340.cc libstdc++-v3/testsuite/23_containers/map: 14340.cc libstdc++-v3/testsuite/23_containers/multimap: 14340.cc libstdc++-v3/testsuite/23_containers/multiset: 14340.cc libstdc++-v3/testsuite/23_containers/set: 14340.cc libstdc++-v3/testsuite/23_containers/vector: 14340.cc Log message: 2004-05-17 Benjamin Kosnik <bkoz@redhat.com> * testsuite/testsuite_hooks.h (__gnu_test::conversion): New class. * testsuite/23_containers/deque/14340.cc: New. * testsuite/23_containers/list/14340.cc: New. * testsuite/23_containers/map/14340.cc: New. * testsuite/23_containers/multimap/14340.cc: New. * testsuite/23_containers/multiset/14340.cc: New. * testsuite/23_containers/set/14340.cc: New. * testsuite/23_containers/vector/14340.cc: New. 2004-05-17 Douglas Gregor <gregod@cs.rpi.edu> PR libstdc++/14340 * include/debug/safe_iterator.h (_Safe_iterator converting constructor): Only allow declaration to instantiate when the incoming _Safe_iterator has exactly the right iterator type. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&r1=1.2479&r2=1.2480 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/debug/safe_iterator.h.diff?cvsroot=gcc&r1=1.3&r2=1.4 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/testsuite_hooks.h.diff?cvsroot=gcc&r1=1.27&r2=1.28 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/deque/14340.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/list/14340.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/map/14340.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/multimap/14340.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/multiset/14340.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/set/14340.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/vector/14340.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1
Subject: Bug 14340 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: bkoz@gcc.gnu.org 2004-05-18 18:41:24 Modified files: libstdc++-v3 : ChangeLog libstdc++-v3/include/debug: safe_iterator.h libstdc++-v3/testsuite: testsuite_hooks.h Added files: libstdc++-v3/testsuite/23_containers/deque: 14340.cc libstdc++-v3/testsuite/23_containers/list: 14340.cc libstdc++-v3/testsuite/23_containers/map: 14340.cc libstdc++-v3/testsuite/23_containers/multimap: 14340.cc libstdc++-v3/testsuite/23_containers/multiset: 14340.cc libstdc++-v3/testsuite/23_containers/set: 14340.cc libstdc++-v3/testsuite/23_containers/vector: 14340.cc Log message: 2004-05-18 Benjamin Kosnik <bkoz@redhat.com> * testsuite/testsuite_hooks.h (__gnu_test::conversion): New class. * testsuite/23_containers/deque/14340.cc: New. * testsuite/23_containers/list/14340.cc: New. * testsuite/23_containers/map/14340.cc: New. * testsuite/23_containers/multimap/14340.cc: New. * testsuite/23_containers/multiset/14340.cc: New. * testsuite/23_containers/set/14340.cc: New. * testsuite/23_containers/vector/14340.cc: New. 2004-05-18 Douglas Gregor <gregod@cs.rpi.edu> PR libstdc++/14340 * include/debug/safe_iterator.h (_Safe_iterator converting constructor): Only allow declaration to instantiate when the incoming _Safe_iterator has exactly the right iterator type. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.2224.2.106&r2=1.2224.2.107 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/debug/safe_iterator.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.2.8.1&r2=1.2.8.2 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/testsuite_hooks.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.25.4.2&r2=1.25.4.3 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/deque/14340.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/list/14340.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/map/14340.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/multimap/14340.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/multiset/14340.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/set/14340.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/vector/14340.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
Fixed in 3.4/mainline.