From 36a60721ceccdb41ccd01d603e7c92ff7c2bae1a Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Tue, 18 Dec 2012 16:46:30 +0000 Subject: Added static_assert to std::get(std::array) calls to catch "out of bounds" calls llvm-svn: 170435 --- .../sequences/array/array.tuple/get.fail.cpp | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 libcxx/test/containers/sequences/array/array.tuple/get.fail.cpp (limited to 'libcxx/test/containers/sequences/array/array.tuple/get.fail.cpp') diff --git a/libcxx/test/containers/sequences/array/array.tuple/get.fail.cpp b/libcxx/test/containers/sequences/array/array.tuple/get.fail.cpp new file mode 100644 index 00000000000..26aa5c74190 --- /dev/null +++ b/libcxx/test/containers/sequences/array/array.tuple/get.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template T& get(array& a); + +#include +#include + +int main() +{ + { + typedef double T; + typedef std::array C; + C c = {1, 2, 3.5}; + std::get<3>(c) = 5.5; // Can't get element 3! + } +} -- cgit v1.2.3