c-integer-promotion-and-conversion
Installation
SKILL.md
C Integer Promotions & Conversions
When to use
- Writing arithmetic mixing
int,unsigned,size_t,char,short, or literals. - Reviewing comparisons between signed and unsigned values.
- Calculating buffer/allocation sizes from potentially large inputs (CVE-2022-0185, CVE-2016-8617).
- Diagnosing "works on 64-bit, breaks on 32-bit" (size_t narrowing).
When not to use
- Pure unsigned-only arithmetic with no narrowing (still check overflow — see
c-undefined-behavior). - Floating point conversion (different rules —
FLP). - C++ — use
cpp-object-lifecyclefor C++-specific integer issues (ES.100-107).