* ostream operator<< for volatile void * @ 2021-04-16 0:34 NightStrike 2021-04-16 6:59 ` Jonathan Wakely 0 siblings, 1 reply; 6+ messages in thread From: NightStrike @ 2021-04-16 0:34 UTC (permalink / raw) To: gcc-help 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? ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: ostream operator<< for volatile void * 2021-04-16 0:34 ostream operator<< for volatile void * NightStrike @ 2021-04-16 6:59 ` Jonathan Wakely 2021-04-16 7:40 ` NightStrike 0 siblings, 1 reply; 6+ messages in thread From: Jonathan Wakely @ 2021-04-16 6:59 UTC (permalink / raw) To: NightStrike; +Cc: gcc-help 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? > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: ostream operator<< for volatile void * 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 0 siblings, 2 replies; 6+ messages in thread From: NightStrike @ 2021-04-16 7:40 UTC (permalink / raw) To: Jonathan Wakely; +Cc: gcc-help 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. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: ostream operator<< for volatile void * 2021-04-16 7:40 ` NightStrike @ 2021-04-16 7:42 ` Jonathan Wakely 2021-04-16 8:07 ` Marc Glisse 1 sibling, 0 replies; 6+ messages in thread From: Jonathan Wakely @ 2021-04-16 7:42 UTC (permalink / raw) To: NightStrike; +Cc: gcc-help On Fri, 16 Apr 2021, 08:40 NightStrike, <nightstrike@gmail.com> 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. > Printing volatile addresses is not commonly needed. > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: ostream operator<< for volatile void * 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 1 sibling, 1 reply; 6+ messages in thread From: Marc Glisse @ 2021-04-16 8:07 UTC (permalink / raw) To: NightStrike; +Cc: gcc-help 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. -- Marc Glisse ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: ostream operator<< for volatile void * 2021-04-16 8:07 ` Marc Glisse @ 2021-04-23 16:04 ` Jonathan Wakely 0 siblings, 0 replies; 6+ messages in thread From: Jonathan Wakely @ 2021-04-23 16:04 UTC (permalink / raw) To: gcc-help 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-04-23 16:04 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-04-16 0:34 ostream operator<< for volatile void * 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 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).