From patchwork Thu Feb 17 23:45:16 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Jonathan Wakely
X-Patchwork-Id: 1594526
Return-Path:
X-Original-To: incoming@patchwork.ozlabs.org
Delivered-To: patchwork-incoming@bilbo.ozlabs.org
Authentication-Results: bilbo.ozlabs.org;
dkim=pass (1024-bit key;
unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256
header.s=default header.b=aCR6UOtv;
dkim-atps=neutral
Authentication-Results: ozlabs.org;
spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org
(client-ip=8.43.85.97; helo=sourceware.org;
envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org;
receiver=)
Received: from sourceware.org (server2.sourceware.org [8.43.85.97])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest
SHA256)
(No client certificate requested)
by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K0BLj07w4z9sFt
for ; Fri, 18 Feb 2022 10:46:51 +1100 (AEDT)
Received: from server2.sourceware.org (localhost [IPv6:::1])
by sourceware.org (Postfix) with ESMTP id 4D514385B83F
for ; Thu, 17 Feb 2022 23:46:49 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4D514385B83F
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org;
s=default; t=1645141609;
bh=aLbDZHIHcR6MSfmy22UoojWNMOXgZc+AXw+rNhYmyVc=;
h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post:
List-Help:List-Subscribe:From:Reply-To:From;
b=aCR6UOtvJQWOjFY3SKkfamqNwRpGQYTR/x/tN3Y2QSJtpd/nEwY3kXz9D0CvQSLCK
3z+bKrOJAcLNpTFK1s7lwjZGnWASuBGE1mGTgvUTZCWqdQNrJwWmXl8U42DvUBijcx
Ds1CEOduWXzjWIsbKgMiFoVdsfhgFKvVQIoeHCQU=
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 70182385BF81
for ; Thu, 17 Feb 2022 23:45:22 +0000 (GMT)
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 70182385BF81
Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com
[209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS
(version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
us-mta-6-rW3nBT6ENPSpOhNf6RoC5Q-1; Thu, 17 Feb 2022 18:45:18 -0500
X-MC-Unique: rW3nBT6ENPSpOhNf6RoC5Q-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 038D7814243;
Thu, 17 Feb 2022 23:45:18 +0000 (UTC)
Received: from localhost (unknown [10.33.36.25])
by smtp.corp.redhat.com (Postfix) with ESMTP id 6EA121059A79;
Thu, 17 Feb 2022 23:45:17 +0000 (UTC)
To: libstdc++@gcc.gnu.org,
gcc-patches@gcc.gnu.org
Subject: [committed] libstdc++: Deprecate non-standard
std::vector::insert(pos) [PR104559]
Date: Thu, 17 Feb 2022 23:45:16 +0000
Message-Id: <20220217234516.4062041-1-jwakely@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22
X-Mimecast-Spam-Score: 0
X-Mimecast-Originator: redhat.com
X-Spam-Status: No, score=-13.5 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, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE,
URI_HEX autolearn=unavailable autolearn_force=no version=3.4.4
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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+incoming=patchwork.ozlabs.org@gcc.gnu.org
Sender: "Gcc-patches"
Tested powerpc64le-linux, pushed to trunk.
-- >8--
The SGI STL and pre-1998 drafts of the C++ standard had a default
argument for vector::insert(iterator, const bool&) which was
remove by N1051. The default argument is still present in libstdc++ for
some reason. There are no tests verifying it as an extension, so I don't
think it has been kept intentionally.
This removes the default argument but adds an overload without the
second parameter, and adds the deprecated attribute to it. This allows
any code using it to keep working (for now) but with a warning.
libstdc++-v3/ChangeLog:
PR libstdc++/104559
* doc/xml/manual/evolution.xml: Document deprecation.
* doc/html/manual/api.html: Regenerate.
* include/bits/stl_bvector.h (insert(const_iterator, const bool&)):
Remove default argument.
(insert(const_iterator)): New overload with deprecated attribute.
* testsuite/23_containers/vector/bool/modifiers/insert/104559.cc:
New test.
---
libstdc++-v3/doc/html/manual/api.html | 3 +++
libstdc++-v3/doc/xml/manual/evolution.xml | 3 +++
libstdc++-v3/include/bits/stl_bvector.h | 11 +++++++++--
.../vector/bool/modifiers/insert/104559.cc | 13 +++++++++++++
4 files changed, 28 insertions(+), 2 deletions(-)
create mode 100644 libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/104559.cc
diff --git a/libstdc++-v3/doc/html/manual/api.html b/libstdc++-v3/doc/html/manual/api.html
index 26087775708..bbda6f5acf3 100644
--- a/libstdc++-v3/doc/html/manual/api.html
+++ b/libstdc++-v3/doc/html/manual/api.html
@@ -454,6 +454,9 @@ were deprecated for C++11.
were deprecated for C++17.
Non-standard std::pair
constructors were deprecated.
+A non-standard default argument for
+vector<bool>::insert(const_iterator, const bool&)
+was deprecated.
The bitmap
, mt
, and pool
options for --enable-libstdcxx-allocator
were removed.
diff --git a/libstdc++-v3/doc/xml/manual/evolution.xml b/libstdc++-v3/doc/xml/manual/evolution.xml
index f5bc6471465..4923e8c4783 100644
--- a/libstdc++-v3/doc/xml/manual/evolution.xml
+++ b/libstdc++-v3/doc/xml/manual/evolution.xml
@@ -1045,6 +1045,9 @@ were deprecated for C++17.
Non-standard std::pair
constructors were deprecated.
+A non-standard default argument for
+vector<bool>::insert(const_iterator, const bool&)
+was deprecated.
diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h
index 75f38812807..d256af40f40 100644
--- a/libstdc++-v3/include/bits/stl_bvector.h
+++ b/libstdc++-v3/include/bits/stl_bvector.h
@@ -1135,9 +1135,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_GLIBCXX20_CONSTEXPR
iterator
#if __cplusplus >= 201103L
- insert(const_iterator __position, const bool& __x = bool())
+ insert(const_iterator __position, const bool& __x)
#else
- insert(iterator __position, const bool& __x = bool())
+ insert(iterator __position, const bool& __x)
#endif
{
const difference_type __n = __position - begin();
@@ -1149,6 +1149,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
return begin() + __n;
}
+#if _GLIBCXX_USE_DEPRECATED
+ _GLIBCXX_DEPRECATED_SUGGEST("insert(position, false)")
+ iterator
+ insert(const_iterator __position)
+ { return this->insert(__position._M_const_cast(), false); }
+#endif
+
#if __cplusplus >= 201103L
template>
diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/104559.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/104559.cc
new file mode 100644
index 00000000000..1121827477f
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/104559.cc
@@ -0,0 +1,13 @@
+// { dg-options "-Wdeprecated" }
+// { dg-do compile }
+// { dg-require-normal-mode "" }
+
+#include
+
+void
+test01()
+{
+ std::vector v;
+ v.insert(v.begin(), false);
+ v.insert(v.begin()); // { dg-warning "deprecated" }
+}