summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2012-04-23 12:26:43 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2012-04-23 12:26:43 +0000
commit9771644a91afe5c53b0433eaedb1d9976f77d856 (patch)
treec583993f5c7e4cd8411fa5936793efa6ca573929 /libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc
parentff5be0e34e72b6f752da6ad73be280a514bc78b0 (diff)
downloadgcc-9771644a91afe5c53b0433eaedb1d9976f77d856.tar.gz
re PR libstdc++/53080 (tuple interface to std::array doesn't check bounds)
2012-04-23 Paolo Carlini <paolo.carlini@oracle.com> PR libstdc++/53080 * include/std/array (tuple_element, get): static_assert I < N. * testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc: New. * testsuite/23_containers/array/tuple_interface/get_neg.cc: Likewise. * testsuite/23_containers/array/tuple_interface/tuple_element.cc: Fix. From-SVN: r186702
Diffstat (limited to 'libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc')
-rw-r--r--libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc32
1 files changed, 32 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc
new file mode 100644
index 00000000000..ecc25bf8387
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc
@@ -0,0 +1,32 @@
+// { dg-options "-std=gnu++11" }
+// { dg-do compile }
+
+// Copyright (C) 2012 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 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <array>
+
+std::array<int, 1> a{};
+const std::array<int, 1> ca{};
+
+int n1 = std::get<1>(a);
+int n2 = std::get<1>(std::move(a));
+int n3 = std::get<1>(ca);
+
+// { dg-error "static assertion failed" "" { target *-*-* } 275 }
+// { dg-error "static assertion failed" "" { target *-*-* } 283 }
+// { dg-error "static assertion failed" "" { target *-*-* } 291 }