On 07/06/19 16:42 +0100, Jonathan Wakely wrote:
On 01/06/19 15:40 -0400, Ed Smith-Rowland via libstdc++ wrote:
On 6/1/19 2:42 PM, Ville Voutilainen wrote:
On Sat, 1 Jun 2019 at 21:09, Ed Smith-Rowland <3dw...@verizon.net> wrote:
On 5/31/19 6:29 PM, Ville Voutilainen wrote:
On Sat, 1 Jun 2019 at 01:24, Ed Smith-Rowland via libstdc++
<libstd...@gcc.gnu.org> wrote:
Greetings,
Iterators for <array> and <string_view> are usabe in a constexpr context
since C++2017.
This just adds a compile test to make sure and check a box for C++20
p0858 - ConstexprIterator requirements.
Those tests don't use the iterators in a constexpr context. To do
that, maybe do those std::copy operations
in a constexpr function and then initialize a constexpr variable with
the result of a call to that function?
Thanks Ville,
I had completely forgotten to make these test functions constexpr - FIXED.
.but that doesn't enforce a constexpr context. If you add another
function that calls these functions
and initializes a constexpr variable, then we have the enforcement I
seek. Such as
void test2()
{
constexpr char x = test();
}
Ok, third time's a charm.
I was brain dead about the constexpr patch.?? I'm now setting a
constexpr variable from test() in a caller.
But static_assert is a constexpr context no?
Ed
2019-06-03 Edward Smith-Rowland <3dw...@verizon.net>
Test for C++20 p0858 - ConstexprIterator requirements.
* testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc:
New test.
* testsuite/23_containers/array/requirements/constexpr_iter.cc:
New test.
Index: testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc
===================================================================
--- testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc
(nonexistent)
+++ testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc
(working copy)
@@ -0,0 +1,43 @@
+// { dg-do compile { target c++2a } }
Please check the testsuite/libstdc++.log or testsuite/libstdc++.sum
files for the new tests. I expect they are both UNSUPPORTED.
That's because you've given a target c++2a which means they won't be
run unless a suitable -std option is given. And you haven't given one.
You need to add { dg-options "-std=gnu++2a" } before the dg-do line.
Also if the tests are restricted to C++2a then there's no point having
the #if __cplusplus > 201703L check, because that will never be false.
I've enhanced my badtests.awk script to check for this case, and it
found a problem with 24_iterators/container_access.cc (the dg-options
needs to be first or the -std option isn't used when checking the
effective target).
Tested x86_64-linux, committed to trunk.
commit 728a466ed5258be419aecd8cc8dbaa62d8364cba
Author: Jonathan Wakely <jwak...@redhat.com>
Date: Fri Jun 7 20:54:39 2019 +0100
Fix test that gets skipped as unsupported
* testsuite/24_iterators/container_access.cc: Move dg-options before
dg-do directive so the target check uses the -std option.
diff --git a/libstdc++-v3/testsuite/24_iterators/container_access.cc b/libstdc++-v3/testsuite/24_iterators/container_access.cc
index 4346b3b6b8c..b9fd3194fe9 100644
--- a/libstdc++-v3/testsuite/24_iterators/container_access.cc
+++ b/libstdc++-v3/testsuite/24_iterators/container_access.cc
@@ -1,5 +1,5 @@
-// { dg-do run { target c++17 } }
// { dg-options "-std=gnu++17" }
+// { dg-do run { target c++17 } }
// Copyright (C) 2015-2019 Free Software Foundation, Inc.
//