This code compiles, and should not. #include <list> int main( ) { std::list< float >::iterator l_it= NULL ; } Replacing list per vector, it does no more compile, which is a better result. I am not a C++ expert, but after a short reading of the slt_list.h file, I guess that the problem is thet there is a constructor of a base class of list<>::iterator that is not "explicit".
Note ICC also accepts this code too.
Subject: Re: Implicit conversion from NULL to list<T>::iterator "pinskia at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes: | Note ICC also accepts this code too. yes, but that is irrelevant. We don't accept #include <vector> #include <string> int main() { using namespace std; vector<string>::iterator p = NULL; } for proper type checking. The list iterator constructor accepting a pointer should be explicit. Thanks Marc, -- Gaby
(In reply to comment #2) > We don't accept > > #include <vector> > #include <string> > > int main() > { > using namespace std; > vector<string>::iterator p = NULL; > } > > for proper type checking. The list iterator constructor accepting a > pointer should be explicit. Agreed. Likewise for deque::iterator, I suppose. I will work on this.
(In reply to comment #3) > Agreed. Likewise for deque::iterator, I suppose. I will work on this. I meant set::iterator and map::iterator, actually: checked earlier today and forgot that deque is not affected. Anyway, consistency with the behavior of vector.
Subject: Re: Implicit conversion from NULL to list<T>::iterator "pcarlini at suse dot de" <gcc-bugzilla@gcc.gnu.org> writes: | Agreed. Likewise for deque::iterator, I suppose. I will work on this. Thank you much Paolo. -- Gaby
Subject: Bug 23781 CVSROOT: /cvs/gcc Module name: gcc Changes by: paolo@gcc.gnu.org 2005-09-11 09:48:41 Modified files: libstdc++-v3 : ChangeLog libstdc++-v3/include/ext: slist libstdc++-v3/include/tr1: hashtable array libstdc++-v3/include/bits: list.tcc stl_list.h stl_tree.h libstdc++-v3/testsuite/23_containers/map/operators: 1_neg.cc libstdc++-v3/testsuite/23_containers/set/operators: 1_neg.cc Added files: libstdc++-v3/testsuite/ext/slist: 23781.cc libstdc++-v3/testsuite/tr1/6_containers/unordered: 23781.cc libstdc++-v3/testsuite/23_containers/list: 23781.cc libstdc++-v3/testsuite/23_containers/map: 23781.cc libstdc++-v3/testsuite/23_containers/multimap: 23781.cc libstdc++-v3/testsuite/23_containers/multiset: 23781.cc libstdc++-v3/testsuite/23_containers/set: 23781.cc Log message: 2005-09-11 Paolo Carlini <pcarlini@suse.de> PR libstdc++/23781 * include/bits/stl_list.h (_List_iterator<>:: _List_iterator(_List_node_base*), _List_const_iterator<>:: _List_const_iterator(const _List_node_base*)): Make explicit. (list<>::begin(), list<>::end(), list<>::pop_back()): Adjust consistently. * include/bits/list.tcc (list<>::insert, list<>::erase): Adjust consistently. * include/bits/stl_tree.h (_Rb_tree_iterator<>:: _Rb_tree_iterator(_Link_type), _Rb_tree_const_iterator<>:: _Rb_tree_const_iterator(_Link_type)): Make explicit. (_Rb_tree<>::begin(), _Rb_tree<>::end()): Adjust consistently. * include/ext/slist (_Slist_iterator<>::_Slist_iterator(_Node*)): Make explicit. (slist<>::erase(iterator), slist<>::erase(iterator, iterator)): Adjust consistently. * include/tr1/hashtable (hashtable_iterator<>:: hashtable_iterator(hash_node<>**)): Make explicit. * testsuite/23_containers/list/23781.cc: New. * testsuite/23_containers/map/23781.cc: Likewise. * testsuite/23_containers/multimap/23781.cc: Likewise. * testsuite/23_containers/multiset/23781.cc: Likewise. * testsuite/23_containers/set/23781.cc: Likewise. * testsuite/ext/slist/23781.cc: Likewise. * testsuite/tr1/6_containers/unordered/23781.cc: Likewise. * testsuite/23_containers/map/operators/1_neg.cc: Adjust dg-error line numbers. * testsuite/23_containers/set/operators/1_neg.cc: Likewise. * include/tr1/array (array<>::begin(), array<>::end()): Adjust stylistically for consistency with the other containers. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&r1=1.3094&r2=1.3095 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/ext/slist.diff?cvsroot=gcc&r1=1.27&r2=1.28 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/tr1/hashtable.diff?cvsroot=gcc&r1=1.8&r2=1.9 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/tr1/array.diff?cvsroot=gcc&r1=1.7&r2=1.8 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/ext/slist/23781.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/tr1/6_containers/unordered/23781.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/list.tcc.diff?cvsroot=gcc&r1=1.21&r2=1.22 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_list.h.diff?cvsroot=gcc&r1=1.51&r2=1.52 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_tree.h.diff?cvsroot=gcc&r1=1.47&r2=1.48 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/list/23781.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/map/23781.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/map/operators/1_neg.cc.diff?cvsroot=gcc&r1=1.7&r2=1.8 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/multimap/23781.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/multiset/23781.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/set/23781.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/23_containers/set/operators/1_neg.cc.diff?cvsroot=gcc&r1=1.7&r2=1.8
Fixed for 4.1.