Re: ostream operator<< for volatile void *

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 16 Apr 2021, 08:40 NightStrike, <nightstrike@xxxxxxxxx> wrote:

> On Fri, Apr 16, 2021 at 2:59 AM Jonathan Wakely <jwakely.gcc@xxxxxxxxx>
> wrote:
> > On Fri, 16 Apr 2021, 02:43 NightStrike via Gcc-help, <
> gcc-help@xxxxxxxxxxx> 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.
>


Printing volatile addresses is not commonly needed.

>



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux