This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Test for C++20 p0858 - ConstexprIterator requirements.
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: Ed Smith-Rowland <3dw4rd at verizon dot net>
- Cc: Ville Voutilainen <ville dot voutilainen at gmail dot com>, "libstdc++ at gcc dot gnu dot org" <libstdc++ at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>, Jonathan Wakely <jwakely dot gcc at gmail dot com>
- Date: Fri, 7 Jun 2019 16:42:11 +0100
- Subject: Re: Test for C++20 p0858 - ConstexprIterator requirements.
- References: <a16d4ac2-f12e-d3a7-4593-aa9dd490ee1f@verizon.net> <CAFk2RUbbxOxjj2Zn1h5-sA2LSuXm+fsNXkpq6j8ypGwfOFqRBg@mail.gmail.com> <b18757f4-ef76-2233-daea-aeca1e831f1b@verizon.net> <CAFk2RUbe-JL9ZYaneFCiWfctc=QBLv2-eTiHAA=B0zTWo_Gsug@mail.gmail.com> <2c21a1c3-074a-3075-d4f0-9dfb50602f39@verizon.net>
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 <3dw4rd@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++
<libstdc++@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 <3dw4rd@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.