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 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 Content-Type: text/plain Content-Transfer-Encoding: 8bit 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 List-Id: 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 } -- 2.41.0