From patchwork Tue May 14 14:05:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1935057 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BIL09AHw; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VdypP1hpqz20dM for ; Wed, 15 May 2024 00:06:53 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B5665387543F for ; Tue, 14 May 2024 14:06:50 +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.129.124]) by sourceware.org (Postfix) with ESMTPS id 0388B3870C37 for ; Tue, 14 May 2024 14:06:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0388B3870C37 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 0388B3870C37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715695594; cv=none; b=Nbb9meuTCXXaJnBplwc6jnz4ETyQOwMTkrAuUCbl9s6n5DYQ57wjT9EH+5A2m3LYYIxtu4woayzRoa+ou78eZWwNEwrn+cbp+0JW9Gb5zSYwABEbTbvGStd9ru8awaO1vV/yrfYg9wR3LvjpGI87B3InutlFIkE7SsEmxRqhiMA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715695594; c=relaxed/simple; bh=78Xebl4OSHScLvKhwltbDM2zJvYPSMIMgljh134ePEA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=F+srQ0a/AevNA2GFwaRop7Jo5FjZj6ldNdApkvuJMxvpDaerBjMUIGUUIpNdj8LTZY5GRHi21izB/qiTUv8Vk8TCSA55XjAqZ59EwjOBJaSaDXzZ5KmF+HyVr6K2TrNW72jaOKO6NBNTirfOl16efpNKyocoOuVBaHnDMPP35w8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1715695592; 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=O0BgdzKB4srJ8EzaDm+1skSY3o/BSoEvnvE7bZo+CUo=; b=BIL09AHwOfc+U1PNB3yl5mfGmAHxTcPK78SqR6Zlry/MydNodaJzHTcIEew3oaEnzI6TWY unWw4yU513lJn6zt8RKP1ERXmS/SvS76NoAblKwDTI370sNtgg65CFVtZB4PEjdTNCFQJx exs0lruCWaojHsQxmf2cYA0v0o7vnXg= 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-187-3Bw3CafrNZODshdok3l-rQ-1; Tue, 14 May 2024 10:06:29 -0400 X-MC-Unique: 3Bw3CafrNZODshdok3l-rQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 21D8E1C2D1C5; Tue, 14 May 2024 14:06:29 +0000 (UTC) Received: from localhost (unknown [10.42.28.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id E58A6115573; Tue, 14 May 2024 14:06:28 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Guard dynamic_cast use in src/c++23/print.cc [PR115015] Date: Tue, 14 May 2024 15:05:48 +0100 Message-ID: <20240514140628.454181-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.6 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_H4, RCVD_IN_MSPIKE_WL, 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 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Tested x86_64-linux, x86_64-w64-mingw32. Pushed to trunk. Backport to gcc-14 to follow. -- >8 -- Do not use dynamic_cast unconditionally, in case libstdc++ is built with -fno-rtti. libstdc++-v3/ChangeLog: PR libstdc++/115015 * src/c++23/print.cc (__open_terminal(streambuf*)) [!__cpp_rtti]: Do not use dynamic_cast. --- libstdc++-v3/src/c++23/print.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libstdc++-v3/src/c++23/print.cc b/libstdc++-v3/src/c++23/print.cc index aceca6f9139..99a19cd4500 100644 --- a/libstdc++-v3/src/c++23/print.cc +++ b/libstdc++-v3/src/c++23/print.cc @@ -87,7 +87,7 @@ namespace void* __open_terminal(std::streambuf* sb) { -#ifndef _GLIBCXX_USE_STDIO_PURE +#if ! defined _GLIBCXX_USE_STDIO_PURE && defined __cpp_rtti using namespace __gnu_cxx; if (auto fb = dynamic_cast*>(sb))