From patchwork Wed Jul 5 06:40:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 115950 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp1671865vqx; Tue, 4 Jul 2023 23:43:56 -0700 (PDT) X-Google-Smtp-Source: APBJJlFgmnduU6YcY/1ASF4OBZl5OOnTs0djwD1jmnDxiFroP9CInh2UR8lH0poEXkrXNIRp3zdL X-Received: by 2002:a17:906:19ca:b0:965:6b9e:7ded with SMTP id h10-20020a17090619ca00b009656b9e7dedmr10787783ejd.42.1688539436553; Tue, 04 Jul 2023 23:43:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688539436; cv=none; d=google.com; s=arc-20160816; b=0HcPI3BWqnRwe9g4GHrmNXBwvJTTyRFQj/hgeFym8AxD7ToE9+sV7hCev6M0QlolhB OYHlAf5mngbfMg6dewcBQeeNdwg21Y3pfM+NZ5pcI9U8XVAzTj1gPdcR8IjwGBiUt7Lx eUzqpxZoHr2FhNs3nAiXoykLjlmN7GRISsVPUTSHO2QZ0oMCDklaPaIjavH/KGaqdg6Y KNjcHXrQDMO1ytq6HNg2xajshZnkPbL0eCnkYLybFVOdMIVu/rh+ryL+D93qtKLBu0J3 JwRmnG3nKpQxUQ0l2xWmSewBg0QSrmrfQ77GyIwXfJm3YJiYgRpqAduGN554V6c2MoFd A8jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=2qTT6OTweDcWwViwqdEd6UQJCjwc22iFyR93kidMuj8=; fh=sJ+2/4g29YdyXkoRrFZSpsL2zxijepB7X/1rB0LDDh8=; b=H2hTNM/GFqhMjyr6LaEFACy8kzfvcXuRRtkD+qy20stvYS4tJ7/Pb5moNFeOWK8VYq awrtG4uqr64a+fA5lKuqmUHZpm2vpTePUZ39lr6+8K1Mh1dniBPSaDlHeL0myTd20orw PpgSNe5VxdHFwL18JDj88Cjsy2Hapd2UE0XV5XRGzhKbERc+Jle3F05ftliOEA1ySFRw prlNomk58rY9n+GJJRcpJ1zxRpBomJjqZigTE8FRcAMNEE4ZP7I4xf2zl2rCQUraFrlC r+PCo76nv7DxaZvu71IIT57uQ9fh0ncmIocDjtXzveJ9WcMM6oy+Q+qicorUlu6t3Fgy CTQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="FGJDF8/d"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id c6-20020aa7df06000000b0051bfc04e1b4si12851849edy.226.2023.07.04.23.43.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jul 2023 23:43:56 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="FGJDF8/d"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 37638386C5AD for ; Wed, 5 Jul 2023 06:42:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 37638386C5AD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688539320; bh=2qTT6OTweDcWwViwqdEd6UQJCjwc22iFyR93kidMuj8=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=FGJDF8/dp8iWVrocY+LFLYsWMKQRvrAILDQjDUkbRJeZBGlhcvGGLPkxP/2W+djG5 wTjGOin9MaSX7mWyIElP4SYMKzF8aEJqIQ3NEQJ+zUgdp+6a7RfIQuNFnLylIYKYk1 vgpaXFU4FFB+eZMEslbPaOnAL2pn5/fduu9NTZWo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 369AE386F44E for ; Wed, 5 Jul 2023 06:41:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 369AE386F44E Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-424-fxmIH_pOMKmm-2RlQLuaMA-1; Wed, 05 Jul 2023 02:41:07 -0400 X-MC-Unique: fxmIH_pOMKmm-2RlQLuaMA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3D368873210; Wed, 5 Jul 2023 06:41:07 +0000 (UTC) Received: from localhost (unknown [10.42.28.54]) by smtp.corp.redhat.com (Postfix) with ESMTP id 06D8C2166B25; Wed, 5 Jul 2023 06:41:06 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Fix std::__uninitialized_default_n for constant evaluation [PR110542] Date: Wed, 5 Jul 2023 07:40:11 +0100 Message-ID: <20230705064106.1143618-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.8 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_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770561927779603029?= X-GMAIL-MSGID: =?utf-8?q?1770561927779603029?= This is a weird one as described in the PR. GCC doesn't complain about this bug, but seems to have a bogus error elsewhere. I'll add a testcase once I've understood/fixed the GCC error. Tested x86_64-linux. Pushed to trunk. -- >8 -- libstdc++-v3/ChangeLog: PR libstdc++/110542 * include/bits/stl_uninitialized.h (__uninitialized_default_n): Do not use std::fill_n during constant evaluation. --- libstdc++-v3/include/bits/stl_uninitialized.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libstdc++-v3/include/bits/stl_uninitialized.h b/libstdc++-v3/include/bits/stl_uninitialized.h index 6752c6b5746..be7b4afdd05 100644 --- a/libstdc++-v3/include/bits/stl_uninitialized.h +++ b/libstdc++-v3/include/bits/stl_uninitialized.h @@ -695,6 +695,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION inline _ForwardIterator __uninitialized_default_n(_ForwardIterator __first, _Size __n) { +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return __uninitialized_default_n_1:: + __uninit_default_n(__first, __n); +#endif + typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType; // See uninitialized_fill_n for the conditions for using std::fill_n.