diff mbox series

[committed] libstdc++: Guard dynamic_cast use in src/c++23/print.cc [PR115015]

Message ID 20240514140628.454181-1-jwakely@redhat.com
State New
Headers show
Series [committed] libstdc++: Guard dynamic_cast use in src/c++23/print.cc [PR115015] | expand

Commit Message

Jonathan Wakely May 14, 2024, 2:05 p.m. UTC
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 mbox series

Patch

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<stdio_sync_filebuf<char>*>(sb))