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 50389385701F for ; Wed, 24 Mar 2021 08:59:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 50389385701F 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-252-0wTNJ9FSPKuxkb1StAhg1A-1; Wed, 24 Mar 2021 04:59:09 -0400 X-MC-Unique: 0wTNJ9FSPKuxkb1StAhg1A-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 65AE9100747D; Wed, 24 Mar 2021 08:59:08 +0000 (UTC) Received: from localhost (unknown [10.33.36.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01B681007606; Wed, 24 Mar 2021 08:59:07 +0000 (UTC) Date: Wed, 24 Mar 2021 08:59:07 +0000 From: Jonathan Wakely To: Alexandre Oliva Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Subject: Re: require et random_device for cons token test Message-ID: <20210324085907.GD3008@redhat.com> References: MIME-Version: 1.0 In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DIET_1, 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: Wed, 24 Mar 2021 08:59:17 -0000 On 24/03/21 03:53 -0300, Alexandre Oliva wrote: > >On target systems that don't support any random_device, not even the >default one, It should be impossible to have no random_device. As a fallback a pseudo random number generator should be used. >other random_device constructor tests are disabled by >dg-require-effective-target random_device. The token.cc also >exercises the default constructor, in a way that doesn't expect an >exception to be raised, but it's not guarded by the same requirement. > >Other potentially-raising ctors in token.cc expect exceptions and >handle them, but the ("default")-constructed one does not, so the >program terminates and the test fails without exercising the other >constructor variants. Why does the "default" token cause an exception? >This patch arranges to disable the test altogether when the >random_device feature is not available. A reasonable alternative >would be to install a std::runtime_error handler around the test01 >body, so that we exercise at least the exception raising, but then >test03 would have to be relaxed, since without even "default", it >likely wouldn't meet the tested requirement there. > >Regstrapped on x86_64-linux-gnu and cross-tested for x86_64-vx7r2 along >with other patches, mostly for the testsuite. Ok to install? No, that would disable the test for Windows, where it works OK. The 'random_device' effective-target is poorly named, it checks whether the _GLIBCXX_USE_RANDOM_TR1 macro is defined, which is even more poorly named. That macro is defined when /dev/random and /dev/urandom are available. But we support std::random_device without those files (e.g. on Windows). If the default constructor throws then that suggests your target is misconfigured. Why isn't the mt19937 PRNG being used? >for libstdc++-v3/ChangeLog > > * testsuite/26_numerics/random/random_device/cons/token.cc: > Require effective target feature random_device. >--- > .../26_numerics/random/random_device/cons/token.cc | 1 + > 1 file changed, 1 insertion(+) > >diff --git a/libstdc++-v3/testsuite/26_numerics/random/random_device/cons/token.cc b/libstdc++-v3/testsuite/26_numerics/random/random_device/cons/token.cc >index defb8d58c586a..105ae0ba87743 100644 >--- a/libstdc++-v3/testsuite/26_numerics/random/random_device/cons/token.cc >+++ b/libstdc++-v3/testsuite/26_numerics/random/random_device/cons/token.cc >@@ -1,4 +1,5 @@ > // { dg-do run { target c++11 } } >+// { dg-require-effective-target random_device } > // { dg-require-cstdint "" } > // > // 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> > > >-- >Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ > Free Software Activist GNU Toolchain Engineer > Vim, Vi, Voltei pro Emacs -- GNUlius Caesar >