diff options
author | bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-07-26 04:21:57 +0000 |
---|---|---|
committer | bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-07-26 04:21:57 +0000 |
commit | 5f431e007703485088d8b85d12dd15ac1d8f7ecc (patch) | |
tree | d45a3f03d5c7d2f895060246c0d5ed54c998a2b1 /libstdc++-v3 | |
parent | f927e607d8bd0d6569445abdf260a501636c0530 (diff) | |
download | gcc-5f431e007703485088d8b85d12dd15ac1d8f7ecc.tar.gz |
2011-07-25 Benjamin Kosnik <bkoz@redhat.com>
* include/std/array (at): Remove constexpr when -fno-exceptions.
* testsuite/23_containers/array/at_neg.cc: Test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@176780 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 5 | ||||
-rw-r--r-- | libstdc++-v3/include/std/array | 15 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/23_containers/array/at_neg.cc | 28 |
3 files changed, 43 insertions, 5 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 79db713ff5b..38833b71e76 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2011-07-25 Benjamin Kosnik <bkoz@redhat.com> + + * include/std/array (at): Remove constexpr when -fno-exceptions. + * testsuite/23_containers/array/at_neg.cc: Test. + 2011-07-25 Paolo Carlini <paolo.carlini@oracle.com> Nathan Ridge <zeratul976@hotmail.com> diff --git a/libstdc++-v3/include/std/array b/libstdc++-v3/include/std/array index 0abb628aded..39573bec844 100644 --- a/libstdc++-v3/include/std/array +++ b/libstdc++-v3/include/std/array @@ -163,16 +163,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return _M_instance[__n]; } +#ifdef __EXCEPTIONS constexpr const_reference at(size_type __n) const { - return __n < _Nm ? _M_instance[__n] : -#ifdef __EXCEPTIONS - throw out_of_range(__N("array::at")); + return __n < _Nm ? + _M_instance[__n] : throw out_of_range(__N("array::at")); + } #else - _M_instance[0]; -#endif + const_reference + at(size_type __n) const + { + return __n < _Nm ? + _M_instance[__n] : __throw_out_of_range(__N("array::at")); } +#endif reference front() diff --git a/libstdc++-v3/testsuite/23_containers/array/at_neg.cc b/libstdc++-v3/testsuite/23_containers/array/at_neg.cc new file mode 100644 index 00000000000..aefc39b75ec --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/array/at_neg.cc @@ -0,0 +1,28 @@ +// { dg-do run { xfail *-*-* } } +// { dg-options "-std=gnu++0x -fno-exceptions" } + +// Copyright (C) 2011 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 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without Pred 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 COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <array> + +int main() +{ + std::array<int, 3> a{{1, 2, 3}}; + auto i = a.at(4); // expected behavior is to either throw or abort + return 0; +} |