adopt-c-bounds-safety

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

How to Use This Skill

如何使用本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
适配或代码修改时,建议先询问用户关于其代码库和目标的澄清问题,再提出修改建议。对于涉及多个文件或非平凡注解决策的复杂任务,先使用规划模式提出实施方案,再进行落地。

-fbounds-safety
Language Extension

-fbounds-safety
语言扩展

-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.
-fbounds-safety
是一种C语言扩展,通过在语言层面强制边界安全来防止内存越界访问。它会在运行时插入自动边界检查,在编译时拒绝不安全的指针操作,并要求程序员提供边界注解,以便编译器能够保证安全性。内存越界访问会变成确定性陷阱,而非可被利用的漏洞。

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 — the workflow for adopting
    -fbounds-safety
    in an existing C project (full and header-only modes).
  • language-overview.md — the language reference for
    -fbounds-safety
    : pointer kinds, annotations, and the rules that govern them.
  • common-patterns-and-pitfalls.md — recipes and anti-patterns encountered during real-world adoption.
在开始适配任务时,你必须通过阅读工具完整阅读以下三份文档,并且在适配流程中任何修改源代码的步骤之前,若这些文档的内容未清晰保留在你的当前上下文里,需再次通过阅读工具重新阅读:
  • adoption-strategies.md — 现有C项目适配
    -fbounds-safety
    的工作流程(完整模式与仅头文件模式)。
  • language-overview.md
    -fbounds-safety
    的语言参考:指针类型、注解及其遵循的规则。
  • common-patterns-and-pitfalls.md — 实际适配过程中遇到的常用方案与反模式。

Other references (read on demand)

其他参考文档(按需阅读)

For compiler flags, Xcode build settings, soft trap mode, and
ptrcheck.h
configuration, read build-settings.md.
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.
关于编译器标志、Xcode构建设置、软陷阱模式和
ptrcheck.h
配置,请阅读build-settings.md
关于运行时调试边界违例——陷阱行为、LLDB命令、宽指针检查、观察点、崩溃日志分析以及软陷阱调试,请阅读runtime-debugging.md