From: Frederick Virchanza Gotham <cauldwell.thomas@gmail.com>
To: Jonathan Wakely <jwakely@redhat.com>
Cc: "libstdc++" <libstdc++@gcc.gnu.org>
Subject: Re: string::iterator should have more error checking
Date: Fri, 24 Jun 2022 12:14:19 +0100 [thread overview]
Message-ID: <CALtZhhOpjbLdvDCAZSxr_m-5NSWry5vrOmB9fZ_zGqUhPhopdQ@mail.gmail.com> (raw)
In-Reply-To: <CACb0b4k_aOruSMAzyWqaDLJMiApgor9xM7x4i_+wWYJDbKudZQ@mail.gmail.com>
On Fri, Jun 24, 2022 at 11:28 AM Jonathan Wakely <jwakely@redhat.com> wrote:
> But &*(s2.cend() + 1u) accesses the byte after the null, doesn't it?
It dereferences a pointer to the byte after the null, certainly, but
there isn't actually any reading/writing of the byte after the null.
I'm pretty sure that's why "-fsanitize" doesn't notice a problem.
However . . . check out the following:
https://godbolt.org/z/jPcv9M6e3
Strangely it doesn't mind printing an invalid "uintptr_t", but it does
mind printing an invalid pointer.
> I don't think that extra check is appropriate though. As you say, it's
> entirely valid according to the standard, so if your application wants
> to disallow that, checking for it belongs in your application.
Yeah maybe I should inherit from string_view.
prev parent reply other threads:[~2022-06-24 11:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-23 21:05 Frederick Virchanza Gotham
2022-06-23 21:26 ` Jonathan Wakely
2022-06-23 22:01 ` Frederick Virchanza Gotham
2022-06-23 22:35 ` Jonathan Wakely
2022-06-24 9:06 ` Frederick Virchanza Gotham
2022-06-24 9:35 ` Jonathan Wakely
2022-06-24 10:10 ` Frederick Virchanza Gotham
2022-06-24 10:28 ` Jonathan Wakely
2022-06-24 11:14 ` Frederick Virchanza Gotham [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=CALtZhhOpjbLdvDCAZSxr_m-5NSWry5vrOmB9fZ_zGqUhPhopdQ@mail.gmail.com \
--to=cauldwell.thomas@gmail.com \
--cc=jwakely@redhat.com \
--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).