Test for C++20 p0858 - ConstexprIterator requirements.

Jonathan Wakely jwakely@redhat.com
Sat Jun 8 20:28:00 GMT 2019


On 08/06/19 12:05 -0400, Ed Smith-Rowland wrote:
>On 6/7/19 11:42 AM, 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 
>>>><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.
>>
>I had supplied the option for gnu++2a by hand and they passed.?? They 
>were not UNSUPPORTED.
>
>I just added the dg-options (at very top) and reran the testsuite 
>without fancy tricks (except for gnu++2a).
>
>I also took out the #if __cplusplus.?? I was just playing around and 
>discovered that these pass in C++17 if you comment out the C++20 
>constexpr algos.
>
>OK for trunk?

OK for trunk.

>Also, we could declare victory for this for gcc-9.?? May I backport 
>after this is in?

Yes, these tests are also OK to backport to gcc-9-branch (assuming
they pass on the branch, which I agree they should do).

Thanks!




More information about the Libstdc++ mailing list