0230. Address sequence header words without negative subscripts
- Status: Accepted
- Date: 2026-11-13
- Plan: M14.12
- Review: Memory and representation
Context
GCC 14 constant propagation diagnoses the guarded negative size_t subscript in string concatenation when the left payload specializes to a literal. The cap-zero guard correctly excludes that read at runtime, but the warning breaks the M14.12 app's stderr-clean build contract.
Decision
Centralize the existing preceding used-length word address in
hrt_seq_used, subtracting sizeof(size_t)
from the payload's uintptr_t address. Use it for
existing buffer header-word reads and writes in the runtime, CLI
whole-file reads, emitted carry/map/par code and tests. Allocation
initialization through the original used pointer is
unaffected. The helper accepts const void * because
hrt_str.data is const char *; its
returned word is writable only for an owned buffer. Only buffer
payloads may reach this helper; keep cap-zero and tip checks
intact. The allocation layout, append behavior and both backend
semantics stay fixed.
Also define _DEFAULT_SOURCE and
_DARWIN_C_SOURCE in the interpreter FFI host before
any include under strict C11 (ADR-0152). The host always defines
them, a superset of the C backend, which emits them only when
p.arenas != 0 || p.features != 0. This is intentional
and safe: trusted app headers can need POSIX or Darwin
declarations regardless of IR runtime features, and the macros
only expose more declarations in the separate host translation
unit. No language or diagnostic contract changes.
Alternatives considered
- Suppress array-bounds warnings or add a pragma — hides unrelated defects and does not repair the problematic address expression.
- Subtract through a char pointer — retains GCC's literal-object provenance; integer arithmetic directly avoids the negative object-relative subscript.
- Only define
_GNU_SOURCEfor the host — does not provide macOS's_DARWIN_C_SOURCEenvironment or the existing C preamble's macro set.
Consequences
Production flags remain unchanged. A small unsanitized C regression retains the failing constant-propagation shape; existing sanitizer tests continue to check header alignment, snapshot preservation and cap-zero views. Address conversion relies on the runtime's existing uintptr_t-capable POSIX targets.