public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: Jonny Grant <jg@jguk.org>
Cc: libstdc++@gcc.gnu.org
Subject: Re: libstdc++ Chapter 28. Demangling example
Date: Fri, 31 Mar 2023 17:18:15 +0100	[thread overview]
Message-ID: <CAH6eHdQ3yUo4ZE351zvEM3rqtvBoAGRumwU4w0tDaxshG+ua6Q@mail.gmail.com> (raw)
In-Reply-To: <03e9c7d6-95a0-bd2e-fa31-91919ad76f3f@jguk.org>

On Fri, 31 Mar 2023 at 16:24, Jonny Grant <jg@jguk.org> wrote:
>
> Hello
>
> I tried out this code. Maybe I'm doing something wrong?
>
> https://godbolt.org/z/Y78h4f1W6
>
> https://gcc.gnu.org/onlinedocs/gcc-12.2.0/libstdc++/manual/manual/ext_demangling.html
>
> However only get reduced output after status -2 is returned:
>
> std::bad_exception      =>
>
> Looks like std::cout gets broken by the nullptr realname (that's a frustration). So I put an if(realname) in the godbolt link above.

N.B. passing a null pointer to printf("%s", ptr) is undefined.
Printing "(null)" is not required by the standards.

Anyway, the exception classes haven't printed their mangled name for
many many years, if they ever did. Only the second part of the
example, using typeid, is valid.

> Maybe it's also a good time to update the example abi::__cxa_demangle call from those 0 parameters to be NULL?

Maybe nullptr.

  reply	other threads:[~2023-03-31 16:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-31 15:24 Jonny Grant
2023-03-31 16:18 ` Jonathan Wakely [this message]
2023-03-31 20:38   ` Jonny Grant
2023-04-04 11:26     ` Jonathan Wakely
2023-04-12 15:09       ` Jonny Grant
2023-04-12 15:36         ` Jonathan Wakely
2023-04-12 16:07           ` Jonny Grant
2023-04-18 13:00             ` Jonny Grant
2023-04-18 14:49               ` Jonathan Wakely
2023-04-18 22:50                 ` Jonny Grant
2023-04-18 23:12                   ` Jonathan Wakely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAH6eHdQ3yUo4ZE351zvEM3rqtvBoAGRumwU4w0tDaxshG+ua6Q@mail.gmail.com \
    --to=jwakely.gcc@gmail.com \
    --cc=jg@jguk.org \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).