public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/106926] string_view construction from literal string containing null/zero should warn
Date: Tue, 13 Sep 2022 14:48:30 +0000	[thread overview]
Message-ID: <bug-106926-4-r1PV6rLZqk@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-106926-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106926

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Blocks|                            |87403
   Last reconfirmed|                            |2022-09-13
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
           Severity|normal                      |enhancement

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Is this a real problem you've seen in the wild?

The same argument applies to std::string, doesn't it?

To generalise it, I think we would probably want a new attribute telling the
compiler that a character pointer argument will be passed to strlen, and only
that many bytes used (i.e. it's treated as a "null-terminated byte string" in
ISO C++ terminology). Then the compiler can warn if an argument to that
function has unreachable characters.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87403
[Bug 87403] [Meta-bug] Issues that suggest a new warning

  reply	other threads:[~2022-09-13 14:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-13 12:27 [Bug c++/106926] New: " jzwinck at gmail dot com
2022-09-13 14:48 ` redi at gcc dot gnu.org [this message]
2022-09-15 18:21 ` [Bug c++/106926] " jzwinck at gmail dot com
2022-09-15 20:21 ` redi at gcc dot gnu.org
2022-09-16 14:24 ` jzwinck at gmail dot com

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=bug-106926-4-r1PV6rLZqk@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).