C Bounds Safety

superagents-lab/xcode27-skills/c-bounds-safety

by superagents-lab6f9ff8d5ad6000491cb0f483a776b7062e41cd97No licenseListed Oct 9, 2026Updated Oct 9, 2026

Guide for the C -fbounds-safety language extension. Covers the language model, pointer annotations, adopting bounds-safety in existing C code, compiler build settings and modes, and runtime debugging of bounds violations.

Instructions onlySoftware Development
AI-generated overview

Guide to the C -fbounds-safety extension: pointer annotations, adoption in existing code, build settings, and runtime debugging.

What it does
Explains the -fbounds-safety C language extension, which enforces bounds safety at the language level with automatic runtime bounds checks and compile-time rejection of unsafe pointer operations. It documents pointer kinds and annotations such as counted_by, sized_by, ended_by, single, indexable, bidi_indexable, unsafe_indexable, null_terminated, and terminated_by, along with helper functions and macros like unsafe_forge_bidi_indexable and __ptrcheck_abi_assume_single. It also covers adoption workflows for existing C projects, compiler build settings and modes, and runtime debugging of bounds violations.
When to use it
Use when reading, reviewing, comparing, debugging, or analyzing C code that has adopted -fbounds-safety or is being migrated to it. It also applies when working with bounds annotations, ptrcheck.h, or related helper macros, and when diagnosing bounds violations at runtime. It is meant for adoption and code-change tasks in existing C codebases.
Requirements
No scripts; instructions and reference documents only. Reading the bundled reference files requires file access. No packages, credentials, or network access are needed.

How to Use This Skill

When helping with -fbounds-safety adoption or code changes, ask clarifying questions about the user's codebase and goals before suggesting changes. For complex tasks involving multiple files or non-trivial annotation decisions, use plan mode to propose an approach before implementing.

-fbounds-safety Language Extension

-fbounds-safety is a C language extension that prevents out-of-bounds memory access by enforcing bounds safety at the language level. It inserts automatic bounds checks at runtime, rejects unsafe pointer operations at compile time, and requires programmers to provide bounds annotations so the compiler can guarantee safety. Out-of-bounds accesses become deterministic traps instead of exploitable vulnerabilities.

Detailed Documentation

Required reading before adoption work

You MUST have fully read the following three documents (via the Read tool) at the start of an adoption task, and re-read them via the Read tool before any source-modifying step in the adoption workflow unless their content is verifiably fresh in your active context:

  • adoption-strategies.md [blocked] — the workflow for adopting -fbounds-safety in an existing C project (full and header-only modes).
  • language-overview.md [blocked] — the language reference for -fbounds-safety: pointer kinds, annotations, and the rules that govern them.
  • common-patterns-and-pitfalls.md [blocked] — recipes and anti-patterns encountered during real-world adoption.

Other references (read on demand)

For compiler flags, Xcode build settings, soft trap mode, and ptrcheck.h configuration, read build-settings.md [blocked].

For debugging bounds violations at runtime — trap behavior, LLDB commands, wide pointer inspection, watchpoints, crash log analysis, and soft trap debugging, read runtime-debugging.md [blocked].

Source and attribution

Source:superagents-lab/xcode27-skillsinc-bounds-safetyat commit6f9ff8d

License: No license

Content belongs to its original authors. SourceWeft indexes it from a public repository.

Report or request removal