libstdc++-v3/ChangeLog:

        PR libstdc++/125450
        * include/std/optional (range_format): Do not define for
        freestanding.
---

Tested x86_64-linux (also with -ffreestanding).

Pushed to trunk. Backport to gcc-16 to follow.

 libstdc++-v3/include/std/optional | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/std/optional 
b/libstdc++-v3/include/std/optional
index 8d6d049e8ccc..dec1a50413ab 100644
--- a/libstdc++-v3/include/std/optional
+++ b/libstdc++-v3/include/std/optional
@@ -60,7 +60,9 @@
 # include <concepts>
 #endif
 #ifdef __cpp_lib_optional_range_support // C++ >= 26
-# include <bits/formatfwd.h>
+# if _GLIBCXX_HOSTED
+#  include <bits/formatfwd.h>
+# endif
 # include <bits/ranges_base.h>
 # include <bits/range_access.h>
 #endif
@@ -2285,9 +2287,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     ranges::enable_borrowed_range<optional<_Tp&>> = true;
 #endif
 
+#if _GLIBCXX_HOSTED
   template<typename _Tp>
     inline constexpr range_format
       format_kind<optional<_Tp>> = range_format::disabled;
+#endif
 #endif // __cpp_lib_optional_range_support
 
 #undef _GLIBCXX_USE_CONSTRAINTS_FOR_OPTIONAL
-- 
2.54.0

Reply via email to