public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/107781] strchrnul' was not declared in this scope; did you mean 'strchr'? For contracts for canadian compilation
Date: Tue, 22 Nov 2022 11:04:00 +0000 [thread overview]
Message-ID: <bug-107781-4-0uJY7ON4pJ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107781-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107781
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #4)
> If we don't want to introduce a configure check for strchrnul then this
> would work:
>
> --- a/gcc/cp/contracts.cc
> +++ b/gcc/cp/contracts.cc
> @@ -210,8 +210,8 @@ lookup_concrete_semantic (const char *name)
> static bool
> role_name_equal (const char *role, const char *name)
> {
> - size_t role_len = strchrnul (role, ':') - role;
> - size_t name_len = strchrnul (name, ':') - name;
> + size_t role_len = strcspn (role, ":");
> + size_t name_len = strcspn (name, ":");
> if (role_len != name_len)
> return false;
> return strncmp (role, name, role_len) == 0;
Yes, though I bet strcspn is often slower, because it has to support many
reject characters, not just 2 (the one specified plus '\0').
Though, on glibc it won't be much slower, due to:
if (__glibc_unlikely (reject[0] == '\0')
|| __glibc_unlikely (reject[1] == '\0'))
return __strchrnul (str, reject [0]) - str;
done at the start of strcspn.
next prev parent reply other threads:[~2022-11-22 11:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-21 7:25 [Bug c++/107781] New: " unlvsur at live dot com
2022-11-21 9:13 ` [Bug c++/107781] " schwab@linux-m68k.org
2022-11-21 10:35 ` redi at gcc dot gnu.org
2022-11-21 14:01 ` dje at gcc dot gnu.org
2022-11-21 22:44 ` jason at gcc dot gnu.org
2022-11-22 10:58 ` redi at gcc dot gnu.org
2022-11-22 11:01 ` jakub at gcc dot gnu.org
2022-11-22 11:04 ` jakub at gcc dot gnu.org [this message]
2022-11-22 14:30 ` cvs-commit at gcc dot gnu.org
2022-11-22 14:47 ` jason at gcc dot gnu.org
2022-11-28 22:38 ` [Bug c++/107781] [13 Regression] " pinskia at gcc dot gnu.org
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-107781-4-0uJY7ON4pJ@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).