public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: gcc-help <gcc-help@gcc.gnu.org>
Subject: Re: ostream operator<< for volatile void *
Date: Fri, 23 Apr 2021 17:04:01 +0100	[thread overview]
Message-ID: <CAH6eHdR3zz=_StD0zBEC5qgrFnhPN9QsMZq-BcZYd5gnYA_mfA@mail.gmail.com> (raw)
In-Reply-To: <c01863a0-261c-6496-1166-f298154c9bcc@grove.saclay.inria.fr>

On Fri, 16 Apr 2021 at 09:54, Marc Glisse <marc.glisse@inria.fr> wrote:
>
> On Fri, 16 Apr 2021, NightStrike via Gcc-help wrote:
>
> > On Fri, Apr 16, 2021 at 2:59 AM Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> >> On Fri, 16 Apr 2021, 02:43 NightStrike via Gcc-help, <gcc-help@gcc.gnu.org> wrote:
> >>>
> >>> Currently, printing a "void *" works fine, and printing a "volatile
> >>> void *" fails with a very unclear error.  This appears to be due to
> >>> the nonexistence of a function that can handle a volatile pointer.
> >>> While I am guessing that it is not covered by the standard, would GCC
> >>> folks consider having a GCC extension that can properly print it?
> >>
> >>
> >> No, I don't think so. Can't you just use const_cast?
> >
> > Yes, and I can also just write the overload myself (which is what I
> > ultimately did) as:
> >
> > inline std::ostream & operator<<(std::ostream & os, void const volatile * p) {
> >        return os << const_cast<void const *>(p);
> > }
> >
> > But, I find it surprising as a user that I have to do this, and I
> > don't understand the rationale for why the standard would
> > intentionally leave it out.
>
> You could try proposing the extra overload(s) on
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals (or maybe as a
> replacement for the void const* one?), this is much less formal than
> sending a paper to the C++ committee and could get some quick feedback. Or
> of course you can directly write a paper for WG21...
>
> Nowadays, gcc tries to minimize new non-standard extensions, so the way in
> is through the standard.

In fact there is already a proposal, waiting to be reviewed by LWG:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1147r0.html

      reply	other threads:[~2021-04-23 16:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-16  0:34 NightStrike
2021-04-16  6:59 ` Jonathan Wakely
2021-04-16  7:40   ` NightStrike
2021-04-16  7:42     ` Jonathan Wakely
2021-04-16  8:07     ` Marc Glisse
2021-04-23 16:04       ` Jonathan Wakely [this message]

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='CAH6eHdR3zz=_StD0zBEC5qgrFnhPN9QsMZq-BcZYd5gnYA_mfA@mail.gmail.com' \
    --to=jwakely.gcc@gmail.com \
    --cc=gcc-help@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).