[gcc r17-811] libstdc++: Fix <optional> for freestanding [PR125450]
Jonathan Wakely
redi@gcc.gnu.org
Tue May 26 11:26:15 GMT 2026
https://gcc.gnu.org/g:23b9ac257cf508bc4fa479c82fcfc768c4abcd79
commit r17-811-g23b9ac257cf508bc4fa479c82fcfc768c4abcd79
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Tue May 26 10:50:53 2026 +0100
libstdc++: Fix <optional> for freestanding [PR125450]
libstdc++-v3/ChangeLog:
PR libstdc++/125450
* include/std/optional (range_format): Do not define for
freestanding.
Diff:
---
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
More information about the Libstdc++-cvs
mailing list