From patchwork Sat Nov 11 00:44:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 164052 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1953vqg; Fri, 10 Nov 2023 18:15:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IGeBn/gbDcJWfkGkMuL1u1/JCvSDNQB5FOlH41l2PTNPpqLsqDchp7mReLpCjizREBAwt8z X-Received: by 2002:a05:6102:f06:b0:45f:5d1:9c62 with SMTP id v6-20020a0561020f0600b0045f05d19c62mr1343310vss.19.1699668921522; Fri, 10 Nov 2023 18:15:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699668921; cv=pass; d=google.com; s=arc-20160816; b=AQVmIgYGMmFn8sLfqIlOXK5ND1KFZWD5Eu6THZninFRWt+DvawulvOvKfsVXI5MiMB eVvX64e6GntxSRxlM9Yrl6Psnq9S4rv40bNgjPcKRC1sCBpzFzPupKkRnYLKyi4yFlEV SJN6egfM/U7Zk3Mj+gmhx7j6oJguIvnW4Su2WrHSOS5AtZzaXPMosuZYPGLMCltkQFbk SdRd2nEU3TgoVP2H/7jEP/4FgYIwiw+VnKq3235UnEgNSUFFuL27u0yjTU3FkQgjLZu1 HMhFlcJfZzbuv+oeBW6qhUNW9cN0A0YaaI9piozsfeQAeVyPwb2E2Pf+FgLCspwGnQio EN/A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=xeeIqAtY0ZAsUQNKQuF98Pirq2vlDNQutjzsUyVHXBI=; fh=sJ+2/4g29YdyXkoRrFZSpsL2zxijepB7X/1rB0LDDh8=; b=i8XGC151KJrQg3jtewoeoBFfsS4eMScg0U0LSrNvAPm9Ych7nWUHts9NpqH+EizIxE gUjl43/052Z1llF3P/1IiAJJ8Vlvw7WJmOg8+5L7oIfW4aYiAvBWYadkqBmhsGIeVQCq TOqhjj0ZClmyvY4Aht1tAWQtqxLTsZCX3ReDjCyg5v30qfjKZrF7w2M35l1Url7tIh6l oyCisprdmYe8io/QHw7i54EgGg8XRGwFL7Qnq3/D2c03T7z+79ODm0j451bi0di1hdfI uWi5RS/NA8Z6dQLHw2j20dtXSazK4nZQkNP0ynutHSp1ZThiGsh0v4Py6uRAch9EUuMZ qOzg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fiECJMr5; arc=pass (i=1); 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=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id o7-20020ac87c47000000b00421ba874426si699280qtv.696.2023.11.10.18.15.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Nov 2023 18:15:21 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=fiECJMr5; arc=pass (i=1); 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=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 50C933889E2C for ; Sat, 11 Nov 2023 00:46:36 +0000 (GMT) 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 AB0BE388A023 for ; Sat, 11 Nov 2023 00:45:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AB0BE388A023 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AB0BE388A023 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699663510; cv=none; b=dF2rNIYKhOmB4MRWKSQ9b21QVKJC2sHsFyFgpOpBTlJCJEnbwSqMAwe16ADE8orRXdrKlx9/++no9+oFcbn9VF+0QhOYaXGD5v9WFdZgLOF0+SsyMukjOrqZLO5F3pnEQxmEGyXUOrqPHHY/FhZlI6u4FcAkWvUoFkdo5awh2o8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699663510; c=relaxed/simple; bh=m+SHwrHSSyAb3knjp8jc42RTgq249X/Om6hgNoTt9Ro=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=E5umFwcVJnKpOf3zYJ6ngaYvST2wyrpr2Q2urVf9qeVc5/S4+BzULb91ij8mXPtPVe2C5SgcngtW7B0F9rWw+baqZDBzgpWBuvSnBauxhtK92JQfUzVCFDEiHbOu2J+f0rE4FuLfC+48gJ05yFtrjId/KUowaucBzq90KlKVk+A= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699663509; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xeeIqAtY0ZAsUQNKQuF98Pirq2vlDNQutjzsUyVHXBI=; b=fiECJMr5F6Du5ldJ8LZTZbORlOrcT77EAIuOscilnzxOhoI0f9pInqzV7OKi6fbI3UxciQ OCshrJPTZ8tP05mM49hdMQAgi3+BSzhxyWXwtJHV32MnnH/wKzAayYVuZ19f8V+VSh/Vkm MsOI4KRLeHwrrM3ld5gYokPFpy+pKHA= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-284-Lox5CpqVMZWeM8jzLhapWg-1; Fri, 10 Nov 2023 19:45:06 -0500 X-MC-Unique: Lox5CpqVMZWeM8jzLhapWg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D698229ABA27; Sat, 11 Nov 2023 00:45:05 +0000 (UTC) Received: from localhost (unknown [10.42.28.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id A18CB492BE7; Sat, 11 Nov 2023 00:45:05 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Add static_assert to std::integer_sequence [PR112473] Date: Sat, 11 Nov 2023 00:44:59 +0000 Message-ID: <20231111004505.78351-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.0 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_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, URI_HEX autolearn=unavailable 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782232039400575906 X-GMAIL-MSGID: 1782232039400575906 Tested x86_64-linux. Pushed to trunk. -- >8 -- C++20 allows class types as non-type template parameters, but std::integer_sequence explicitly disallows them. Enforce that. libstdc++-v3/ChangeLog: PR libstdc++/112473 * include/bits/utility.h (integer_sequence): Add static_assert. * testsuite/20_util/integer_sequence/112473.cc: New test. --- libstdc++-v3/include/bits/utility.h | 3 +++ libstdc++-v3/testsuite/20_util/integer_sequence/112473.cc | 8 ++++++++ 2 files changed, 11 insertions(+) create mode 100644 libstdc++-v3/testsuite/20_util/integer_sequence/112473.cc diff --git a/libstdc++-v3/include/bits/utility.h b/libstdc++-v3/include/bits/utility.h index 8766dfbc15f..ebcf5ba36b2 100644 --- a/libstdc++-v3/include/bits/utility.h +++ b/libstdc++-v3/include/bits/utility.h @@ -166,6 +166,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct integer_sequence { +#if __cplusplus >= 202002L + static_assert(is_integral_v<_Tp>); +#endif typedef _Tp value_type; static constexpr size_t size() noexcept { return sizeof...(_Idx); } }; diff --git a/libstdc++-v3/testsuite/20_util/integer_sequence/112473.cc b/libstdc++-v3/testsuite/20_util/integer_sequence/112473.cc new file mode 100644 index 00000000000..14abfbc8149 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/integer_sequence/112473.cc @@ -0,0 +1,8 @@ +// { dg-do compile { target c++20 } } + +// PR libstdc++/112473 - integer_sequence accepts non-integer types + +#include + +std::integer_sequence, std::pair{0, 0}> ic; +// { dg-error "static assertion failed" "" { target *-*-* } 0 }