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 B5D783850617 for ; Mon, 12 Dec 2022 14:01:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B5D783850617 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670853680; 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=4EhvhXiVB3lOCsbjjm0BrG2xCfrqKZITJ+DiUK+tNf4=; b=GrdTp4BjbyeLUuQYHnbwWDk1pOre6oo/og4H9WY+M1lWcl1ZucX1S34IC0MVrvk6p45c9z 5BTcRACm+i56AgNYowo9/IxGJf6EYdqASt0xH3rCZBFx2PZsBC0ODsYVWZRS4s2TVa0HvW tRBBMLg/D2dguIJCK1avX6zXy5bXYeU= 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) From: Jonathan Wakely 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 Content-Type: text/plain Content-Transfer-Encoding: 8bit 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=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-- 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>; -- 2.38.1