2004-05-17 Benjamin Kosnik * 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 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. Index: include/debug/safe_iterator.h =================================================================== RCS file: /cvs/gcc/gcc/libstdc++-v3/include/debug/safe_iterator.h,v retrieving revision 1.3 diff -c -p -r1.3 safe_iterator.h *** include/debug/safe_iterator.h 16 Apr 2004 19:04:04 -0000 1.3 --- include/debug/safe_iterator.h 18 May 2004 03:26:09 -0000 *************** *** 35,40 **** --- 35,41 ---- #include #include #include + #include namespace __gnu_debug { *************** namespace __gnu_debug *** 88,93 **** --- 89,95 ---- typedef iterator_traits<_Iterator> _Traits; public: + typedef _Iterator _Base_iterator; typedef typename _Traits::iterator_category iterator_category; typedef typename _Traits::value_type value_type; typedef typename _Traits::difference_type difference_type; *************** namespace __gnu_debug *** 132,138 **** * @pre @p x is not singular */ template ! _Safe_iterator(const _Safe_iterator<_MutableIterator, _Sequence>& __x) : _Safe_iterator_base(__x, _M_constant()), _M_current(__x.base()) { _GLIBCXX_DEBUG_VERIFY(!__x._M_singular(), --- 134,146 ---- * @pre @p x is not singular */ template ! _Safe_iterator( ! const _Safe_iterator<_MutableIterator, ! typename std::__enable_if< ! _Sequence, ! (std::__are_same<_MutableIterator, ! typename _Sequence::iterator::_Base_iterator>::_M_type) ! >::_M_type>& __x) : _Safe_iterator_base(__x, _M_constant()), _M_current(__x.base()) { _GLIBCXX_DEBUG_VERIFY(!__x._M_singular(), Index: testsuite/testsuite_hooks.h =================================================================== RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/testsuite_hooks.h,v retrieving revision 1.27 diff -c -p -r1.27 testsuite_hooks.h *** testsuite/testsuite_hooks.h 1 Apr 2004 09:16:36 -0000 1.27 --- testsuite/testsuite_hooks.h 18 May 2004 03:26:09 -0000 *************** *** 1,7 **** // -*- C++ -*- // Utility subroutines for the C++ library testsuite. // ! // Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the --- 1,7 ---- // -*- C++ -*- // Utility subroutines for the C++ library testsuite. // ! // Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the *************** namespace __gnu_test *** 340,345 **** --- 340,363 ---- inline bool operator==(const copy_tracker& lhs, const copy_tracker& rhs) { return lhs.id() == rhs.id(); } + + // Class for checking required type conversions, implicit and + // explicit for given library data structures. + template + struct conversion + { + typedef typename _Container::const_iterator const_iterator; + + // Implicit conversion iterator to const_iterator. + static const_iterator + iterator_to_const_iterator() + { + _Container v; + const_iterator it = v.begin(); + const_iterator end = v.end(); + return it == end ? v.end() : it; + } + }; } // namespace __gnu_test namespace std Index: testsuite/23_containers/deque/14340.cc =================================================================== RCS file: testsuite/23_containers/deque/14340.cc diff -N testsuite/23_containers/deque/14340.cc *** /dev/null 1 Jan 1970 00:00:00 -0000 --- testsuite/23_containers/deque/14340.cc 18 May 2004 03:26:10 -0000 *************** *** 0 **** --- 1,42 ---- + // -*- C++ -*- + + // Copyright (C) 2004 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library is free + // software; you can redistribute it and/or modify it under the + // terms of the GNU General Public License as published by the + // Free Software Foundation; either version 2, or (at your option) + // any later version. + + // This library is distributed in the hope that it will be useful, + // but WITHOUT ANY WARRANTY; without even the implied warranty of + // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + // GNU General Public License for more details. + + // You should have received a copy of the GNU General Public License along + // with this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // As a special exception, you may use this file as part of a free software + // library without restriction. Specifically, if other files instantiate + // templates or use macros or inline functions from this file, or you compile + // this file and link it with other files to produce an executable, this + // file does not by itself cause the resulting executable to be covered by + // the GNU General Public License. This exception does not however + // invalidate any other reasons why the executable file might be covered by + // the GNU General Public License. + + #include + #include + + // { dg-options "-D_GLIBCXX_DEBUG" } + // { dg-do compile } + + // libstdc++/14340 + int main() + { + typedef std::deque container; + __gnu_test::conversion::iterator_to_const_iterator(); + return 0; + } Index: testsuite/23_containers/list/14340.cc =================================================================== RCS file: testsuite/23_containers/list/14340.cc diff -N testsuite/23_containers/list/14340.cc *** /dev/null 1 Jan 1970 00:00:00 -0000 --- testsuite/23_containers/list/14340.cc 18 May 2004 03:26:10 -0000 *************** *** 0 **** --- 1,42 ---- + // -*- C++ -*- + + // Copyright (C) 2004 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library is free + // software; you can redistribute it and/or modify it under the + // terms of the GNU General Public License as published by the + // Free Software Foundation; either version 2, or (at your option) + // any later version. + + // This library is distributed in the hope that it will be useful, + // but WITHOUT ANY WARRANTY; without even the implied warranty of + // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + // GNU General Public License for more details. + + // You should have received a copy of the GNU General Public License along + // with this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // As a special exception, you may use this file as part of a free software + // library without restriction. Specifically, if other files instantiate + // templates or use macros or inline functions from this file, or you compile + // this file and link it with other files to produce an executable, this + // file does not by itself cause the resulting executable to be covered by + // the GNU General Public License. This exception does not however + // invalidate any other reasons why the executable file might be covered by + // the GNU General Public License. + + #include + #include + + // { dg-options "-D_GLIBCXX_DEBUG" } + // { dg-do compile } + + // libstdc++/14340 + int main() + { + typedef std::list container; + __gnu_test::conversion::iterator_to_const_iterator(); + return 0; + } Index: testsuite/23_containers/map/14340.cc =================================================================== RCS file: testsuite/23_containers/map/14340.cc diff -N testsuite/23_containers/map/14340.cc *** /dev/null 1 Jan 1970 00:00:00 -0000 --- testsuite/23_containers/map/14340.cc 18 May 2004 03:26:10 -0000 *************** *** 0 **** --- 1,42 ---- + // -*- C++ -*- + + // Copyright (C) 2004 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library is free + // software; you can redistribute it and/or modify it under the + // terms of the GNU General Public License as published by the + // Free Software Foundation; either version 2, or (at your option) + // any later version. + + // This library is distributed in the hope that it will be useful, + // but WITHOUT ANY WARRANTY; without even the implied warranty of + // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + // GNU General Public License for more details. + + // You should have received a copy of the GNU General Public License along + // with this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // As a special exception, you may use this file as part of a free software + // library without restriction. Specifically, if other files instantiate + // templates or use macros or inline functions from this file, or you compile + // this file and link it with other files to produce an executable, this + // file does not by itself cause the resulting executable to be covered by + // the GNU General Public License. This exception does not however + // invalidate any other reasons why the executable file might be covered by + // the GNU General Public License. + + #include + #include + + // { dg-options "-D_GLIBCXX_DEBUG" } + // { dg-do compile } + + // libstdc++/14340 + int main() + { + typedef std::map container; + __gnu_test::conversion::iterator_to_const_iterator(); + return 0; + } Index: testsuite/23_containers/multimap/14340.cc =================================================================== RCS file: testsuite/23_containers/multimap/14340.cc diff -N testsuite/23_containers/multimap/14340.cc *** /dev/null 1 Jan 1970 00:00:00 -0000 --- testsuite/23_containers/multimap/14340.cc 18 May 2004 03:26:10 -0000 *************** *** 0 **** --- 1,42 ---- + // -*- C++ -*- + + // Copyright (C) 2004 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library is free + // software; you can redistribute it and/or modify it under the + // terms of the GNU General Public License as published by the + // Free Software Foundation; either version 2, or (at your option) + // any later version. + + // This library is distributed in the hope that it will be useful, + // but WITHOUT ANY WARRANTY; without even the implied warranty of + // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + // GNU General Public License for more details. + + // You should have received a copy of the GNU General Public License along + // with this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // As a special exception, you may use this file as part of a free software + // library without restriction. Specifically, if other files instantiate + // templates or use macros or inline functions from this file, or you compile + // this file and link it with other files to produce an executable, this + // file does not by itself cause the resulting executable to be covered by + // the GNU General Public License. This exception does not however + // invalidate any other reasons why the executable file might be covered by + // the GNU General Public License. + + #include + #include + + // { dg-options "-D_GLIBCXX_DEBUG" } + // { dg-do compile } + + // libstdc++/14340 + int main() + { + typedef std::multimap container; + __gnu_test::conversion::iterator_to_const_iterator(); + return 0; + } Index: testsuite/23_containers/multiset/14340.cc =================================================================== RCS file: testsuite/23_containers/multiset/14340.cc diff -N testsuite/23_containers/multiset/14340.cc *** /dev/null 1 Jan 1970 00:00:00 -0000 --- testsuite/23_containers/multiset/14340.cc 18 May 2004 03:26:10 -0000 *************** *** 0 **** --- 1,42 ---- + // -*- C++ -*- + + // Copyright (C) 2004 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library is free + // software; you can redistribute it and/or modify it under the + // terms of the GNU General Public License as published by the + // Free Software Foundation; either version 2, or (at your option) + // any later version. + + // This library is distributed in the hope that it will be useful, + // but WITHOUT ANY WARRANTY; without even the implied warranty of + // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + // GNU General Public License for more details. + + // You should have received a copy of the GNU General Public License along + // with this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // As a special exception, you may use this file as part of a free software + // library without restriction. Specifically, if other files instantiate + // templates or use macros or inline functions from this file, or you compile + // this file and link it with other files to produce an executable, this + // file does not by itself cause the resulting executable to be covered by + // the GNU General Public License. This exception does not however + // invalidate any other reasons why the executable file might be covered by + // the GNU General Public License. + + #include + #include + + // { dg-options "-D_GLIBCXX_DEBUG" } + // { dg-do compile } + + // libstdc++/14340 + int main() + { + typedef std::multiset container; + __gnu_test::conversion::iterator_to_const_iterator(); + return 0; + } Index: testsuite/23_containers/set/14340.cc =================================================================== RCS file: testsuite/23_containers/set/14340.cc diff -N testsuite/23_containers/set/14340.cc *** /dev/null 1 Jan 1970 00:00:00 -0000 --- testsuite/23_containers/set/14340.cc 18 May 2004 03:26:10 -0000 *************** *** 0 **** --- 1,42 ---- + // -*- C++ -*- + + // Copyright (C) 2004 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library is free + // software; you can redistribute it and/or modify it under the + // terms of the GNU General Public License as published by the + // Free Software Foundation; either version 2, or (at your option) + // any later version. + + // This library is distributed in the hope that it will be useful, + // but WITHOUT ANY WARRANTY; without even the implied warranty of + // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + // GNU General Public License for more details. + + // You should have received a copy of the GNU General Public License along + // with this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // As a special exception, you may use this file as part of a free software + // library without restriction. Specifically, if other files instantiate + // templates or use macros or inline functions from this file, or you compile + // this file and link it with other files to produce an executable, this + // file does not by itself cause the resulting executable to be covered by + // the GNU General Public License. This exception does not however + // invalidate any other reasons why the executable file might be covered by + // the GNU General Public License. + + #include + #include + + // { dg-options "-D_GLIBCXX_DEBUG" } + // { dg-do compile } + + // libstdc++/14340 + int main() + { + typedef std::set container; + __gnu_test::conversion::iterator_to_const_iterator(); + return 0; + } Index: testsuite/23_containers/vector/14340.cc =================================================================== RCS file: testsuite/23_containers/vector/14340.cc diff -N testsuite/23_containers/vector/14340.cc *** /dev/null 1 Jan 1970 00:00:00 -0000 --- testsuite/23_containers/vector/14340.cc 18 May 2004 03:26:10 -0000 *************** *** 0 **** --- 1,42 ---- + // -*- C++ -*- + + // Copyright (C) 2004 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library is free + // software; you can redistribute it and/or modify it under the + // terms of the GNU General Public License as published by the + // Free Software Foundation; either version 2, or (at your option) + // any later version. + + // This library is distributed in the hope that it will be useful, + // but WITHOUT ANY WARRANTY; without even the implied warranty of + // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + // GNU General Public License for more details. + + // You should have received a copy of the GNU General Public License along + // with this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // As a special exception, you may use this file as part of a free software + // library without restriction. Specifically, if other files instantiate + // templates or use macros or inline functions from this file, or you compile + // this file and link it with other files to produce an executable, this + // file does not by itself cause the resulting executable to be covered by + // the GNU General Public License. This exception does not however + // invalidate any other reasons why the executable file might be covered by + // the GNU General Public License. + + #include + #include + + // { dg-options "-D_GLIBCXX_DEBUG" } + // { dg-do compile } + + // libstdc++/14340 + int main() + { + typedef std::vector container; + __gnu_test::conversion::iterator_to_const_iterator(); + return 0; + }