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.