This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [PATCH] libstdc++/72745 add static assertion for invalid tuple access
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Sun, 31 Jul 2016 19:14:11 +0100
- Subject: Re: [PATCH] libstdc++/72745 add static assertion for invalid tuple access
- Authentication-results: sourceware.org; auth=none
- References: <20160731171004.GA12566@redhat.com>
On 31/07/16 18:10 +0100, Jonathan Wakely wrote:
PR libstdc++/72745
* include/std/array (get): Use positive message for static assertions.
* include/std/functional (_Safe_tuple_element_t): Fix indentation.
* include/std/tuple (tuple_element<I, tuple<>>): Add partial
specialization for invalid indices, with static assertion.
* testsuite/20_util/tuple/element_access/get_neg.cc: New test.
This improves the diagnostic for std::get<1>( tuple<int>{} ) by adding
a static assertion that the index is in range.
Tested powerpc64-linux, committed to trunk.
While working on this I noticed that the test for std::get<I> on a
std::pair only runs as C++14, but should also run for C++11 (which is
easy to do with the new effective target support I committed earlier
today).
Tested x86_64-linux, committed to trunk.
commit f24865f80fa2b5d6bebebb2656ba86aafc8312fe
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Sun Jul 31 18:25:39 2016 +0100
Allow std::pair test to run in C++11 mode too
* testsuite/20_util/pair/astuple/get_neg.cc: Use effective-target
c++11 instead of setting -std=gnu++14.
diff --git a/libstdc++-v3/testsuite/20_util/pair/astuple/get_neg.cc b/libstdc++-v3/testsuite/20_util/pair/astuple/get_neg.cc
index f980b87..ea251b8 100644
--- a/libstdc++-v3/testsuite/20_util/pair/astuple/get_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/pair/astuple/get_neg.cc
@@ -1,5 +1,4 @@
-// { dg-do compile }
-// { dg-options "-std=gnu++14" }
+// { dg-do compile { target c++11 } }
// Copyright (C) 2013-2016 Free Software Foundation, Inc.
//