From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 052CF395441A for ; Tue, 22 Jun 2021 20:29:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 052CF395441A Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-308-EXvnOiSOOBCU77VntvqSWg-1; Tue, 22 Jun 2021 16:29:54 -0400 X-MC-Unique: EXvnOiSOOBCU77VntvqSWg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 910D7804309; Tue, 22 Jun 2021 20:29:53 +0000 (UTC) Received: from localhost (unknown [10.33.36.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2DFB75D9DE; Tue, 22 Jun 2021 20:29:52 +0000 (UTC) Date: Tue, 22 Jun 2021 21:29:52 +0100 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Implement LWG 3422 for std::seed_seq Message-ID: MIME-Version: 1.0 X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="Lg9hv+VJtDjEI4un" Content-Disposition: inline X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Jun 2021 20:29:58 -0000 --Lg9hv+VJtDjEI4un Content-Type: text/plain; charset=us-ascii Content-Disposition: inline This ensures that the std::seed_seq initializer-list constructor will not be used for list-initialization unless the initializers in the list are integers. This allows list-initialization syntax to be used with a pair of pointers and for that to use the appropriate constructor. Signed-off-by: Jonathan Wakely libstdc++-v3/ChangeLog: * include/bits/random.h (seed_seq): Constrain initializer-list constructor. * include/bits/random.tcc (seed_seq): Add template parameter. * testsuite/26_numerics/random/seed_seq/cons/default.cc: Check for noexcept. * testsuite/26_numerics/random/seed_seq/cons/initlist.cc: Check constraints. Tested powerpc64le-linux. Committed to trunk. --Lg9hv+VJtDjEI4un Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" commit 6c63cb231e4cf99552bb7904ebe402f7adcafda4 Author: Jonathan Wakely Date: Tue Jun 22 18:05:11 2021 libstdc++: Implement LWG 3422 for std::seed_seq This ensures that the std::seed_seq initializer-list constructor will not be used for list-initialization unless the initializers in the list are integers. This allows list-initialization syntax to be used with a pair of pointers and for that to use the appropriate constructor. Signed-off-by: Jonathan Wakely libstdc++-v3/ChangeLog: * include/bits/random.h (seed_seq): Constrain initializer-list constructor. * include/bits/random.tcc (seed_seq): Add template parameter. * testsuite/26_numerics/random/seed_seq/cons/default.cc: Check for noexcept. * testsuite/26_numerics/random/seed_seq/cons/initlist.cc: Check constraints. diff --git a/libstdc++-v3/include/bits/random.h b/libstdc++-v3/include/bits/random.h index 0da013c5f45..ed0d7a832f1 100644 --- a/libstdc++-v3/include/bits/random.h +++ b/libstdc++-v3/include/bits/random.h @@ -6073,7 +6073,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : _M_v() { } - template + template>> seed_seq(std::initializer_list<_IntType> __il); template diff --git a/libstdc++-v3/include/bits/random.tcc b/libstdc++-v3/include/bits/random.tcc index 1357e181874..8e2b702b0be 100644 --- a/libstdc++-v3/include/bits/random.tcc +++ b/libstdc++-v3/include/bits/random.tcc @@ -3231,7 +3231,7 @@ namespace __detail } - template + template seed_seq::seed_seq(std::initializer_list<_IntType> __il) { for (auto __iter = __il.begin(); __iter != __il.end(); ++__iter) diff --git a/libstdc++-v3/testsuite/26_numerics/random/seed_seq/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/seed_seq/cons/default.cc index 18f55e723f0..62434a66591 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/seed_seq/cons/default.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/seed_seq/cons/default.cc @@ -25,6 +25,9 @@ #include #include +static_assert( std::is_nothrow_default_constructible::value, + "LWG 3422" ); + void test01() { @@ -34,7 +37,6 @@ test01() seq.generate(foo.begin(), foo.end()); VERIFY( seq.size() == 0 ); - //VERIFY(); } int diff --git a/libstdc++-v3/testsuite/26_numerics/random/seed_seq/cons/initlist.cc b/libstdc++-v3/testsuite/26_numerics/random/seed_seq/cons/initlist.cc index 44b855e5627..1ed9eb784c3 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/seed_seq/cons/initlist.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/seed_seq/cons/initlist.cc @@ -36,6 +36,13 @@ test01() VERIFY( seq.size() == 10 ); } +void +lwg3422() +{ + int i[32] = { }; + std::seed_seq ss{i, i+32}; // LWG 3422 +} + int main() { test01(); --Lg9hv+VJtDjEI4un--