Page MenuHomeFreeBSD

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

Authored by ivy on Mon, Jul 27, 10:31 PM.
Tags
None
Referenced Files
F165038674: D58488.id182842.diff
Wed, Aug 5, 11:35 AM
Unknown Object (File)
Mon, Aug 3, 1:52 AM
Unknown Object (File)
Sun, Aug 2, 6:10 PM
Unknown Object (File)
Sat, Aug 1, 10:47 AM
Unknown Object (File)
Sat, Aug 1, 8:41 AM
Unknown Object (File)
Fri, Jul 31, 3:59 PM
Unknown Object (File)
Fri, Jul 31, 6:18 AM
Unknown Object (File)
Fri, Jul 31, 4:43 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 Skipped
Unit
Tests Skipped
Build Status
Buildable 75182
Build 72065: arc lint + arc unit

Event Timeline

ivy requested review of this revision.Mon, Jul 27, 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.Mon, Jul 27, 11:16 PM
This revision is now accepted and ready to land.Tue, Jul 28, 12:29 AM
This revision was automatically updated to reflect the committed changes.