aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/std
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/include/std')
-rw-r--r--libstdc++-v3/include/std/stacktrace28
-rw-r--r--libstdc++-v3/include/std/utility19
2 files changed, 43 insertions, 4 deletions
diff --git a/libstdc++-v3/include/std/stacktrace b/libstdc++-v3/include/std/stacktrace
index b9e260e..587a163 100644
--- a/libstdc++-v3/include/std/stacktrace
+++ b/libstdc++-v3/include/std/stacktrace
@@ -683,13 +683,32 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
inline ostream&
operator<<(ostream& __os, const stacktrace_entry& __f)
{
+ if (!__f) [[unlikely]]
+ return __os << "<unknown>";
+
string __desc, __file;
int __line;
- if (__f._M_get_info(&__desc, &__file, &__line))
+ if (__f._M_get_info(&__desc, &__file, &__line)) [[likely]]
{
- __os.width(4);
- __os << __desc << " at " << __file << ':' << __line;
+ __os << ' ';
+ if (__desc.empty()) [[unlikely]]
+ __os << "<unknown>";
+ else
+ __os << __desc;
+ if (!__file.empty()) [[likely]]
+ __os << " at " << __file << ':' << __line;
}
+
+ struct _Flag_guard // Set and restore hex format
+ {
+ _Flag_guard(ios& __s) : _M_ios(__s) { }
+ ~_Flag_guard() { _M_ios.setf(_M_f); }
+
+ ios& _M_ios;
+ ios::fmtflags _M_f = _M_ios.setf(ios::hex, ios::basefield);
+ };
+ _Flag_guard __g(__os);
+ __os << " [0x" << __f.native_handle() << ']';
return __os;
}
@@ -697,7 +716,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
inline ostream&
operator<<(ostream& __os, const basic_stacktrace<_Allocator>& __st)
{
- for (stacktrace::size_type __i = 0; __i < __st.size(); ++__i)
+ using size_type = typename basic_stacktrace<_Allocator>::size_type;
+ for (size_type __i = 0, __size = __st.size(); __i < __size; ++__i)
{
__os.width(4);
__os << __i << "# " << __st[__i] << '\n';
diff --git a/libstdc++-v3/include/std/utility b/libstdc++-v3/include/std/utility
index 8a85ccf..3ae1852 100644
--- a/libstdc++-v3/include/std/utility
+++ b/libstdc++-v3/include/std/utility
@@ -98,6 +98,7 @@
#define __glibcxx_want_tuple_element_t
#define __glibcxx_want_tuples_by_type
#define __glibcxx_want_unreachable
+#define __glibcxx_want_observable_checkpoint
#define __glibcxx_want_tuple_like
#define __glibcxx_want_constrained_equality
#include <bits/version.h>
@@ -234,6 +235,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
#endif
+
+#ifdef __cpp_lib_observable_checkpoint // C++ >= 26
+ /// Informs the compiler that prior actions are considered observable.
+ /**
+ * This may be used to limit the extent to which optimisations based on the
+ * assumed unreachability of undefined behaviour can propagate to earlier
+ * code.
+ *
+ * @since C++26
+ */
+ [[__gnu__::__always_inline__]]
+ inline void
+ observable_checkpoint() noexcept
+ {
+ return __builtin_observable_checkpoint();
+ }
+#endif
+
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace