C Bounds Safety

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

作者 superagents-lab6f9ff8d5ad6000491cb0f483a776b7062e41cd97無授權條款收錄於 2026年10月9日更新於 2026年10月9日

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.

AI 產生的概覽

C 語言 -fbounds-safety 擴充指南:指標註解、在既有程式碼中採用、建置設定與執行期除錯。

功能
說明 -fbounds-safety 這個 C 語言擴充,它在語言層級強制邊界安全,自動插入執行期邊界檢查並在編譯期拒絕不安全的指標操作。文件介紹指標種類與註解,例如 counted_by、sized_by、ended_by、single、indexable、bidi_indexable、unsafe_indexable、null_terminated 和 terminated_by,以及 unsafe_forge_bidi_indexable、__ptrcheck_abi_assume_single 等輔助函式與巨集。內容也涵蓋在既有 C 專案中採用此擴充的流程、編譯器建置設定與模式,以及邊界違規的執行期除錯。
適用情境
適用於閱讀、審查、比較、除錯或分析已採用或準備採用 -fbounds-safety 的 C 程式碼。也適用於處理邊界註解、ptrcheck.h 及相關輔助巨集,以及排查執行期的邊界違規。主要針對既有 C 程式庫中的採用與程式碼修改工作。
執行需求
不含指令碼,僅為說明與參考文件;讀取隨附參考檔案需要檔案存取權限。不需要額外套件、憑證或網路存取。

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].

來源與署名

來源:superagents-lab/xcode27-skills位於c-bounds-safety提交6f9ff8d

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架