[PATCH] libstdc++: Improve ostream output for std::stacktrace
Jonathan Wakely
jwakely.gcc@gmail.com
Thu Oct 16 06:42:49 GMT 2025
On Thu, 16 Oct 2025, 07:00 Nathan Myers, <ncm@cantrip.org> wrote:
> On 10/15/25 9:54 PM, Nathan Myers wrote:
> > On 10/15/25 5:02 PM, Jonathan Wakely wrote:
> ...
> >> --- a/libstdc++-v3/include/std/stacktrace
> >> +++ b/libstdc++-v3/include/std/stacktrace
> >> @@ -134,6 +134,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> >> friend ostream&
> >> operator<<(ostream&, const stacktrace_entry&);
> >> + struct _Print_pc
> >> + {
> >> + native_handle_type _M_pc;
> >> +
> >> + friend ostream&
> >> + operator<<(ostream& __os, _Print_pc __pc)
> >> + {
> >> + if (__pc._M_pc != (native_handle_type)-1) [[likely]]
> >> + __os << "[0x" << std::hex << __pc._M_pc << std::dec << ']';
> >
> > Maybe save the output radix, and restore it.
>
> Like
>
> auto __flags = __os.setf(__os.hex, __os.basefield);
> __os << "[0x" << __pc._M_pc << ']';
> __os.flags(__flags);
>
Ah yes, we don't know that it's initially 'dec' so should not set it to
that unconditionally.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20251016/dc15c73d/attachment.htm>
More information about the Libstdc++
mailing list