]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Fix <optional> for freestanding [PR125450]
authorJonathan Wakely <jwakely@redhat.com>
Tue, 26 May 2026 09:50:53 +0000 (10:50 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Tue, 26 May 2026 11:25:53 +0000 (12:25 +0100)
libstdc++-v3/ChangeLog:

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

libstdc++-v3/include/std/optional

index 8d6d049e8cccd96b1511f22c3c5bc7319f27ca45..dec1a50413abe60f952392f19954d424190c2923 100644 (file)
@@ -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