diff options
author | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-09-09 18:40:46 +0000 |
---|---|---|
committer | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-09-09 18:40:46 +0000 |
commit | 49871e2f937ef81bafbb6f26f6997e8bca023afc (patch) | |
tree | 1e08ff84aede6323073ec919c0819bfb164da4d5 /libstdc++-v3/testsuite/23_containers | |
parent | 6b9b992f50f4f0d78e26d3bb4e2378624b344ee6 (diff) | |
download | gcc-49871e2f937ef81bafbb6f26f6997e8bca023afc.tar.gz |
PR libstdc++/54388
* include/std/array (array::at() const): Ensure lvalue result.
* testsuite/23_containers/array/element_access/54388.cc: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@191117 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/23_containers')
-rw-r--r-- | libstdc++-v3/testsuite/23_containers/array/element_access/54388.cc | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/23_containers/array/element_access/54388.cc b/libstdc++-v3/testsuite/23_containers/array/element_access/54388.cc new file mode 100644 index 00000000000..a69a5edb6a0 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/array/element_access/54388.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } +// +// 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> +#include <testsuite_hooks.h> + +struct A +{ + bool valid = true; + ~A() { valid = false; } +}; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + const std::array<A, 1> a; + const A& aa = a.at(0); + VERIFY(aa.valid); +} + +int main() +{ + test01(); +} |