Page MenuHomeFreeBSD

localedef: Const correctness for C23
AcceptedPublic

Authored by ivy on Jul 27 2026, 11:04 PM.
Tags
None
Referenced Files
F169356219: D58496.id.diff
Tue, Sep 1, 7:30 AM
F169350992: D58496.diff
Tue, Sep 1, 7:02 AM
F169225949: D58496.diff
Mon, Aug 31, 11:01 PM
Unknown Object (File)
Sun, Aug 30, 12:56 PM
Unknown Object (File)
Sun, Aug 30, 6:14 AM
Unknown Object (File)
Wed, Aug 26, 1:20 PM
Unknown Object (File)
Wed, Aug 26, 12:27 PM
Unknown Object (File)
Sat, Aug 22, 9:34 AM
Subscribers

Details

Reviewers
markj
des
kevans
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 localedef during
the bootstrap build, since it assumes the return value is always
a mutable pointer.

This code can modify either a const (rodata) string, which happens
to be avoided by accident, or modify const global data. Change the
logic to instead create a local copy of the string and modify that
if needed. This introduces an additional allocation, but this is
not performance-sensitive code.

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 76186
Build 73069: arc lint + arc unit

Event Timeline

ivy requested review of this revision.Jul 27 2026, 11:04 PM

I think it'd be cleaner to drop the const qualifier from yesstr/nostr/yesexpr/noexpr and use strdup() to assign the empty string in this function. But this works too.

This revision is now accepted and ready to land.Jul 28 2026, 1:29 PM

i was trying to avoid adding extra allocations for this group of patches, but i suppose this is not a performance-critical code path, so i'll switch it to use strdup if we think that's neater (i tend to agree, since __DECONST is at least a code smell).

use strdup() instead of __DECONST

This revision now requires review to proceed.Wed, Aug 26, 10:48 AM
This revision is now accepted and ready to land.Wed, Aug 26, 1:25 PM