From patchwork Mon Dec 12 14:01:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 32401 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2258033wrr; Mon, 12 Dec 2022 06:03:07 -0800 (PST) X-Google-Smtp-Source: AA0mqf6loO8K5vJ14HbtBHqCT+zl/5rEGgdRIqC9AkJdmbnOvIpJf4LNqR+7guz1EE3QJKUJ8BW0 X-Received: by 2002:aa7:c79a:0:b0:467:b851:6057 with SMTP id n26-20020aa7c79a000000b00467b8516057mr13384732eds.18.1670853787114; Mon, 12 Dec 2022 06:03:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670853787; cv=none; d=google.com; s=arc-20160816; b=jGObQEa7lIHGtkWWFRjTtLvHJ+roPOk2dM6pUMDPxO1XEYYNCbUa1phjENsFdGfHhx 8JBbHBjPVyq2aSPIDwzoeP4tDGq/1owkndJOESUNryLR1HgwA6yVCYN92NrjIVvJ+Kyt Py7VI0n886S5300auqLQcZothbckabHa3BNP0Tl7jnRqauRzTSbZsxPxuSLskOvjZHv8 /Hdv7bymEXU50G/HnZBd9U1s3okoTAebNolGYFV4LvTI245B9XDIIzxqvwblv1siDS2j DwbpTZpNmqQ9CJVu5mNEnbBxPmbGPUm1VxjdMpN596l6hU07Q5Hk+2guw8eW7qyZedma GNiQ== 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=4EhvhXiVB3lOCsbjjm0BrG2xCfrqKZITJ+DiUK+tNf4=; b=wUpbl9QrCveuk+QoS207GsojyW24/oHtuqGm5DNcYMg8Wd0BKQYoNG5cy3SRjLk6pB 57Xe3lSWZh/Js0s+3YY0Uj+oAz5qM9d09S5MS1ty5Tzg1MNtiN0jMDUjK+AHUiuzhO/B VQ+7urfUzYxAbYgwk21HqZ5zz7Q43JwG8OilsfV9Q2pXXKHcie7PGyuuM5F24+n85clR QbZMlBqWHLc7FfesKXl3r2xBZDUiKJPw5aKX/ZdyADDtEXNsJqBzTXI/XEh6SC1fFe65 vGDtjGw3z9sDLfqLqD0nSfVxmcUmwwhR9KTe/b4FGt8XkBM5Kjknqo76z1h4vlF14ygr tUHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=SKPRNZeS; 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 sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id j7-20020a05640211c700b0046fc7ef9918si3533420edw.588.2022.12.12.06.03.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 06:03:07 -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=@gcc.gnu.org header.s=default header.b=SKPRNZeS; 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 594543850B01 for ; Mon, 12 Dec 2022 14:02:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 594543850B01 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1670853724; bh=4EhvhXiVB3lOCsbjjm0BrG2xCfrqKZITJ+DiUK+tNf4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=SKPRNZeS/Ht0jCrMXmi0GEfk5Vzj059Jhux0LTD+IhISvJ+UlLB7EtxOZvqDMUCAM kdbp304xRWLoibLRQ/Kz8zUCB+hiPxTDr3BCw2dprp/uO0lOtNdXHgZya/lo8sWZO5 Jro2Im9MbaR/Zav26+D5gdOPAAUpQ26cCMISeOXY= 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 CBD1738518A1 for ; Mon, 12 Dec 2022 14:01:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CBD1738518A1 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-398-5GxFiSykNIm3Vq9ogR3pcQ-1; Mon, 12 Dec 2022 09:01:17 -0500 X-MC-Unique: 5GxFiSykNIm3Vq9ogR3pcQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 40C2D38012D1; Mon, 12 Dec 2022 14:01:16 +0000 (UTC) Received: from localhost (unknown [10.33.36.251]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03F8340ED76C; Mon, 12 Dec 2022 14:01:15 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Make operator<< for stacktraces less templated (LWG 3515) Date: Mon, 12 Dec 2022 14:01:13 +0000 Message-Id: <20221212140113.716862-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.2 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_H2, SPF_HELO_NONE, SPF_NONE, TXREP 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?1752017180466814827?= X-GMAIL-MSGID: =?utf-8?q?1752017180466814827?= Tested x86_64-linux. Pushed to trunk. -- >8-- This change was approved for C++23 last month. libstdc++-v3/ChangeLog: * include/std/stacktrace (operator<<): Only output to narrow ostreams (LWG 3515). * testsuite/19_diagnostics/stacktrace/synopsis.cc: --- libstdc++-v3/include/std/stacktrace | 38 +++++++++---------- .../19_diagnostics/stacktrace/synopsis.cc | 11 +++--- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/libstdc++-v3/include/std/stacktrace b/libstdc++-v3/include/std/stacktrace index ec3335e89d8..83c6463b0d8 100644 --- a/libstdc++-v3/include/std/stacktrace +++ b/libstdc++-v3/include/std/stacktrace @@ -165,9 +165,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return __state; } - template - friend basic_ostream<_CharT, _Traits>& - operator<<(basic_ostream<_CharT, _Traits>&, const stacktrace_entry&); + friend ostream& + operator<<(ostream&, const stacktrace_entry&); bool _M_get_info(string* __desc, string* __file, int* __line) const @@ -720,25 +719,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION noexcept(noexcept(__a.swap(__b))) { __a.swap(__b); } - template - inline basic_ostream<_CharT, _Traits>& - operator<<(basic_ostream<_CharT, _Traits>& __os, - const stacktrace_entry& __f) - { - string __desc, __file; - int __line; - if (__f._M_get_info(&__desc, &__file, &__line)) - { - __os.width(4); - __os << __desc << " at " << __file << ':' << __line; - } - return __os; - } + inline ostream& + operator<<(ostream& __os, const stacktrace_entry& __f) + { + string __desc, __file; + int __line; + if (__f._M_get_info(&__desc, &__file, &__line)) + { + __os.width(4); + __os << __desc << " at " << __file << ':' << __line; + } + return __os; + } - template - inline basic_ostream<_CharT, _Traits>& - operator<<(basic_ostream<_CharT, _Traits>& __os, - const basic_stacktrace<_Allocator>& __st) + template + inline ostream& + operator<<(ostream& __os, const basic_stacktrace<_Allocator>& __st) { for (stacktrace::size_type __i = 0; __i < __st.size(); ++__i) { diff --git a/libstdc++-v3/testsuite/19_diagnostics/stacktrace/synopsis.cc b/libstdc++-v3/testsuite/19_diagnostics/stacktrace/synopsis.cc index 72582fa53c6..262abea21ec 100644 --- a/libstdc++-v3/testsuite/19_diagnostics/stacktrace/synopsis.cc +++ b/libstdc++-v3/testsuite/19_diagnostics/stacktrace/synopsis.cc @@ -28,13 +28,12 @@ namespace std template string to_string(const basic_stacktrace& st); - template - basic_ostream& - operator<<(basic_ostream& os, const stacktrace_entry& f); + ostream& + operator<<(ostream& os, const stacktrace_entry& f); - template - basic_ostream& - operator<<(basic_ostream& os, const basic_stacktrace& st); + template + ostream& + operator<<(ostream& os, const basic_stacktrace& st); namespace pmr { using stacktrace = basic_stacktrace>;