diff mbox series

[PR115585] Fix --disable-libstdcxx-verbose abi break

Message ID SA1PR11MB713044B81EAB485B95D8FB7FB2CA2@SA1PR11MB7130.namprd11.prod.outlook.com
State New
Headers show
Series [PR115585] Fix --disable-libstdcxx-verbose abi break | expand

Commit Message

Shengdun Wang June 22, 2024, 5:02 a.m. UTC
From: trcrsired <uwgghhbcad@gmail.com>

__glibcxx_assert_fail is not defined when we disable
the libstdcxx-verbose. This causes ABI break when a
binary is compiled with verbose enabled.

Add bits/c++config.h before headers in assert_fail
---
 libstdc++-v3/src/c++11/assert_fail.cc | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/libstdc++-v3/src/c++11/assert_fail.cc b/libstdc++-v3/src/c++11/assert_fail.cc
index 6d99c7958f3..60fd5ddd210 100644
--- a/libstdc++-v3/src/c++11/assert_fail.cc
+++ b/libstdc++-v3/src/c++11/assert_fail.cc
@@ -22,23 +22,26 @@ 
 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 // <http://www.gnu.org/licenses/>.
 
+#include <bits/c++config.h>
+#ifdef _GLIBCXX_VERBOSE_ASSERT
 #include <cstdio>	// for std::fprintf, stderr
+#endif
 #include <cstdlib>	// for std::abort
 
-#ifdef _GLIBCXX_VERBOSE_ASSERT
 namespace std
 {
   [[__noreturn__]]
   void
-  __glibcxx_assert_fail(const char* file, int line,
-			const char* function, const char* condition) noexcept
+  __glibcxx_assert_fail([[maybe_unused]] const char* file, [[maybe_unused]] int line,
+			[[maybe_unused]] const char* function, [[maybe_unused]] const char* condition) noexcept
   {
+#ifdef _GLIBCXX_VERBOSE_ASSERT
     if (file && function && condition)
       fprintf(stderr, "%s:%d: %s: Assertion '%s' failed.\n",
 	      file, line, function, condition);
     else if (function)
       fprintf(stderr, "%s: Undefined behavior detected.\n", function);
+#endif
     abort();
   }
 }
-#endif