From: paolo Date: Wed, 17 Sep 2008 22:58:38 +0000 (+0000) Subject: 2008-09-17 Paolo Carlini X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=commitdiff_plain;h=7b64e03cdc2be61f271794e45338b3981ff93d29 2008-09-17 Paolo Carlini PR libstdc++/37547 * include/bits/stl_algo.h (min(initializer_list<>), min(initializer_list<>, Compare), max(initializer_list<>), max(initializer_list<>, Compare), minmax(initializer_list<>), minmax(initializer_list<>, Compare)): Fix return type. * include/bits/algorithmfwd.h: Adjust. * testsuite/25_algorithms/headers/algorithm/synopsis.cc: Likewise. * testsuite/25_algorithms/max/requirements/explicit_instantiation/3.cc: Likewise. * testsuite/25_algorithms/max/requirements/explicit_instantiation/ pod2.cc: Likewise. * testsuite/25_algorithms/min/requirements/explicit_instantiation/3.cc: Likewise. * testsuite/25_algorithms/min/requirements/explicit_instantiation/ pod2.cc: Likewise. * testsuite/25_algorithms/minmax/requirements/explicit_instantiation/ 3.cc: Likewise. * testsuite/25_algorithms/minmax/requirements/explicit_instantiation/ pod2.cc: Likewise. * testsuite/25_algorithms/max/37547.cc: New. * testsuite/25_algorithms/min/37547.cc: Likewise. * testsuite/25_algorithms/minmax/37547.cc: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@140435 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 3c2d291778e..0d9e413faa3 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,28 @@ +2008-09-17 Paolo Carlini + + PR libstdc++/37547 + * include/bits/stl_algo.h (min(initializer_list<>), + min(initializer_list<>, Compare), max(initializer_list<>), + max(initializer_list<>, Compare), minmax(initializer_list<>), + minmax(initializer_list<>, Compare)): Fix return type. + * include/bits/algorithmfwd.h: Adjust. + * testsuite/25_algorithms/headers/algorithm/synopsis.cc: Likewise. + * testsuite/25_algorithms/max/requirements/explicit_instantiation/3.cc: + Likewise. + * testsuite/25_algorithms/max/requirements/explicit_instantiation/ + pod2.cc: Likewise. + * testsuite/25_algorithms/min/requirements/explicit_instantiation/3.cc: + Likewise. + * testsuite/25_algorithms/min/requirements/explicit_instantiation/ + pod2.cc: Likewise. + * testsuite/25_algorithms/minmax/requirements/explicit_instantiation/ + 3.cc: Likewise. + * testsuite/25_algorithms/minmax/requirements/explicit_instantiation/ + pod2.cc: Likewise. + * testsuite/25_algorithms/max/37547.cc: New. + * testsuite/25_algorithms/min/37547.cc: Likewise. + * testsuite/25_algorithms/minmax/37547.cc: Likewise. + 2008-09-16 Chris Fairles * testsuite/25_algorithms/min/requirements/explicit_instantiation/3.cc: diff --git a/libstdc++-v3/include/bits/algorithmfwd.h b/libstdc++-v3/include/bits/algorithmfwd.h index 95ff72b79d5..0e2e2c0e277 100644 --- a/libstdc++-v3/include/bits/algorithmfwd.h +++ b/libstdc++-v3/include/bits/algorithmfwd.h @@ -319,27 +319,27 @@ _GLIBCXX_BEGIN_NAMESPACE(std) minmax_element(_FIter, _FIter, _Compare); template - const _Tp& + _Tp min(initializer_list<_Tp>); template - const _Tp& + _Tp min(initializer_list<_Tp>, _Compare); template - const _Tp& + _Tp max(initializer_list<_Tp>); template - const _Tp& + _Tp max(initializer_list<_Tp>, _Compare); template - pair + pair<_Tp, _Tp> minmax(initializer_list<_Tp>); template - pair + pair<_Tp, _Tp> minmax(initializer_list<_Tp>, _Compare); #endif diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h index 42ada9986f3..373881c7f1b 100644 --- a/libstdc++-v3/include/bits/stl_algo.h +++ b/libstdc++-v3/include/bits/stl_algo.h @@ -4094,38 +4094,38 @@ _GLIBCXX_BEGIN_NAMESPACE(std) return std::make_pair(__min, __max); } - // N2722. + // N2722 + fixes. template - inline const _Tp& + inline _Tp min(initializer_list<_Tp> __l) { return *std::min_element(__l.begin(), __l.end()); } template - inline const _Tp& + inline _Tp min(initializer_list<_Tp> __l, _Compare __comp) { return *std::min_element(__l.begin(), __l.end(), __comp); } template - inline const _Tp& + inline _Tp max(initializer_list<_Tp> __l) { return *std::max_element(__l.begin(), __l.end()); } template - inline const _Tp& + inline _Tp max(initializer_list<_Tp> __l, _Compare __comp) { return *std::max_element(__l.begin(), __l.end(), __comp); } template - inline pair + inline pair<_Tp, _Tp> minmax(initializer_list<_Tp> __l) { pair __p = std::minmax_element(__l.begin(), __l.end()); - return std::make_pair(*__p.first, *__p.second); + return std::pair<_Tp, _Tp>(*__p.first, *__p.second); } template - inline pair + inline pair<_Tp, _Tp> minmax(initializer_list<_Tp> __l, _Compare __comp) { pair __p = diff --git a/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc b/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc index 3bc8eb2a764..aa4496b907b 100644 --- a/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc +++ b/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc @@ -533,27 +533,27 @@ namespace std minmax_element(_FIter, _FIter, _Compare); template - const _Tp& + _Tp min(initializer_list<_Tp>); template - const _Tp& + _Tp min(initializer_list<_Tp>, _Compare); template - const _Tp& + _Tp max(initializer_list<_Tp>); template - const _Tp& + _Tp max(initializer_list<_Tp>, _Compare); template - pair + pair<_Tp, _Tp> minmax(initializer_list<_Tp>); template - pair + pair<_Tp, _Tp> minmax(initializer_list<_Tp>, _Compare); #endif diff --git a/libstdc++-v3/testsuite/25_algorithms/max/37547.cc b/libstdc++-v3/testsuite/25_algorithms/max/37547.cc new file mode 100644 index 00000000000..233804c4254 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/max/37547.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include +#include + +// libstdc++/37547 +int test01() +{ + bool test __attribute__((unused)) = true; + + std::vector v{1,2,3,4,5}; + + auto p = std::max({v}); + VERIFY ( p == v ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/3.cc b/libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/3.cc index e4ac6cb607b..1f242c9af39 100644 --- a/libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/3.cc +++ b/libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/3.cc @@ -42,6 +42,6 @@ namespace std typedef value_type* iterator_type; typedef std::less compare_type; - template const value_type& max(initializer_list); - template const value_type& max(initializer_list, compare_type); + template value_type max(initializer_list); + template value_type max(initializer_list, compare_type); } diff --git a/libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/pod2.cc b/libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/pod2.cc index 55f2eae6545..0e623e2e637 100644 --- a/libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/pod2.cc +++ b/libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/pod2.cc @@ -42,6 +42,6 @@ namespace std typedef value_type* iterator_type; typedef std::less compare_type; - template const value_type& max(initializer_list); - template const value_type& max(initializer_list, compare_type); + template value_type max(initializer_list); + template value_type max(initializer_list, compare_type); } diff --git a/libstdc++-v3/testsuite/25_algorithms/min/37547.cc b/libstdc++-v3/testsuite/25_algorithms/min/37547.cc new file mode 100644 index 00000000000..5d0ffd47649 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/min/37547.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include +#include + +// libstdc++/37547 +int test01() +{ + bool test __attribute__((unused)) = true; + + std::vector v{1,2,3,4,5}; + + auto p = std::min({v}); + VERIFY ( p == v ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/3.cc b/libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/3.cc index 1d6e7aedeb8..7faea37947c 100644 --- a/libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/3.cc +++ b/libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/3.cc @@ -42,6 +42,6 @@ namespace std typedef value_type* iterator_type; typedef std::less compare_type; - template const value_type& min(initializer_list); - template const value_type& min(initializer_list, compare_type); + template value_type min(initializer_list); + template value_type min(initializer_list, compare_type); } diff --git a/libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/pod2.cc b/libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/pod2.cc index 98c8413c2a6..4800c1bd1c5 100644 --- a/libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/pod2.cc +++ b/libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/pod2.cc @@ -42,6 +42,6 @@ namespace std typedef value_type* iterator_type; typedef std::less compare_type; - template const value_type& min(initializer_list); - template const value_type& min(initializer_list, compare_type); + template value_type min(initializer_list); + template value_type min(initializer_list, compare_type); } diff --git a/libstdc++-v3/testsuite/25_algorithms/minmax/37547.cc b/libstdc++-v3/testsuite/25_algorithms/minmax/37547.cc new file mode 100644 index 00000000000..21de3907b3e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/minmax/37547.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include +#include + +// libstdc++/37547 +int test01() +{ + bool test __attribute__((unused)) = true; + + std::vector v{1,2,3,4,5}; + + auto p = std::minmax({v}); + VERIFY ( p.first == v ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/3.cc b/libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/3.cc index 71fab66fddd..a6506ca764c 100644 --- a/libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/3.cc +++ b/libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/3.cc @@ -42,8 +42,7 @@ namespace std typedef value_type* iterator_type; typedef std::less compare_type; - template pair - minmax(initializer_list); - template pair - minmax(initializer_list, compare_type); + template pair minmax(initializer_list); + template pair minmax(initializer_list, + compare_type); } diff --git a/libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/pod2.cc b/libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/pod2.cc index d5285930ddf..b31d38d3c89 100644 --- a/libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/pod2.cc +++ b/libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/pod2.cc @@ -42,8 +42,7 @@ namespace std typedef value_type* iterator_type; typedef std::less compare_type; - template pair - minmax(initializer_list); - template pair - minmax(initializer_list, compare_type); + template pair minmax(initializer_list); + template pair minmax(initializer_list, + compare_type); }