On Tue, Nov 22, 2022 at 09:41:24AM +0100, Jakub Jelinek via Gcc-patches wrote:
> On Mon, Nov 21, 2022 at 06:31:47PM -0500, Jason Merrill via Gcc-patches wrote:
> > Tested x86_64-pc-linux-gnu, and also manually changing the
> > HAVE_DECL_STRCHRNUL
> > flag. OK for trunk?
> >
> > -- 8< --
> >
> > The Contracts implementation uses strchrnul, which is a glibc extension, so
> > bootstrap broke on non-glibc targets. I considered unconditionally using a
> > local definition, but I guess we might as well use the libc version if it
> > exists.
> >
> > PR c++/107781
> >
> > gcc/cp/ChangeLog:
> >
> > * contracts.cc (strchrnul): Define if needed.
> >
> > gcc/ChangeLog:
> >
> > * configure.ac: Check for strchrnul.
> > * config.in, configure: Regenerate.
>
> Normally we'd add such a local definition to libiberty, shouldn't we do it
> in this case too?
Or use strcspn as Jonathan posted in the PR, at least glibc will handle
it as strchrnul (start, reject[0]) - start early in the strcspn
implementation.
Jakub