[PATCH] libstdc++: Fix unused variable bootstrap fail.

Iain Sandoe iains.gcc@gmail.com
Wed May 20 06:04:10 GMT 2026


Bootstrap currently fails on x86_64 darwin, fixed thus.
Tested on x86_64-darwin, OK for trunk?
thanks
Iain

--- 8< ---

Since r16-603, we have a variable __limit, that is only used when
exceptions are enabled.  Since we do not enable exceptions for bootstrap
of the compiler, this causes a fail (at least on Darwin) in stage 2
with .../basic_string.tcc:439:23: error: unused variable '__limit' ...

Fixed by making the variable declaration also conditional on
__cpp_exceptions.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.tcc: Only declare __limit if we
	are going to use it.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
---
 libstdc++-v3/include/bits/basic_string.tcc | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc
index 5f83991db83..b3940e1610c 100644
--- a/libstdc++-v3/include/bits/basic_string.tcc
+++ b/libstdc++-v3/include/bits/basic_string.tcc
@@ -433,10 +433,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       if (_M_is_local())
 	return;
 
-#ifdef __glibcxx_allocate_at_least  // C++23
+#if __cpp_exceptions
+#  ifdef __glibcxx_allocate_at_least  // C++23
       const size_type __limit = (__STDCPP_DEFAULT_NEW_ALIGNMENT__ - 1) / sizeof(_CharT);
-#else
+#  else
       const size_type __limit = 0;
+#  endif
 #endif
       const size_type __length = length();
       const size_type __capacity = _M_allocated_capacity;
-- 
2.50.1 (Apple Git-155)



More information about the Libstdc++ mailing list