Page MenuHomeFreeBSD

libc: getopt{,_long}: Const correctness for C23
ClosedPublic

Authored by ivy on Jul 27 2026, 10:31 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Sep 21, 5:57 PM
Unknown Object (File)
Wed, Sep 16, 4:00 AM
Unknown Object (File)
Sun, Sep 13, 10:00 AM
Unknown Object (File)
Sat, Sep 12, 6:03 PM
Unknown Object (File)
Fri, Sep 11, 7:06 AM
Unknown Object (File)
Fri, Sep 11, 1:21 AM
Unknown Object (File)
Thu, Sep 10, 9:47 AM
Unknown Object (File)
Tue, Sep 8, 8:35 PM
Subscribers
None

Details

Summary

On some platforms, e.g. Linux Clang 22.1.8 / glibc 2.43, strchr()
now implements the C23 behaviour where passing a const pointer to
strchr() also returns a const pointer. This breaks getopt during
the bootstrap build, since it assumes the return value is always
a mutable pointer.

Since the pointed-to value is never modified, fix this by making
the pointer const.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

ivy requested review of this revision.Jul 27 2026, 10:31 PM
ivy created this revision.
ivy retitled this revision from libc: getopt{,_long}: const correctness for C23 to libc: getopt{,_long}: Const correctness for C23.Jul 27 2026, 11:16 PM
This revision is now accepted and ready to land.Jul 28 2026, 12:29 AM
This revision was automatically updated to reflect the committed changes.