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)
Sun, Aug 30, 11:11 PM
Unknown Object (File)
Sun, Aug 30, 11:06 PM
Unknown Object (File)
Sun, Aug 30, 3:03 AM
Unknown Object (File)
Fri, Aug 28, 10:05 AM
Unknown Object (File)
Fri, Aug 28, 10:01 AM
Unknown Object (File)
Thu, Aug 27, 10:21 PM
Unknown Object (File)
Mon, Aug 24, 3:11 AM
Unknown Object (File)
Sat, Aug 22, 3:45 AM
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.