adjust-array-indexing-base
Use when array is accessed with direct user input as index (0-based indexing)
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when array is accessed with direct user input as index (0-based indexing)
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when printf statements output strings without trailing newlines
Use when the program accesses a precomputed table using an offset (e.g., arr[n-1]) that introduces an arithmetic operation between the symbolic input and the index
Use when loop variables iterate over character values (e.g., ASCII codes) to represent different operations or choices
Use when code uses a loop to search for an input value in an array and then uses the found index for further computation
Use when code reads a fixed number of characters into an array and only accesses individual elements
Use when code uses an array to store a single character/value that is only accessed at one index
| name | adjust-array-indexing-base |
| description | Use when array is accessed with direct user input as index (0-based indexing) |
A KLEE-coverage code transformation. Applying it rewrites C source so symbolic execution explores more of the program's behavior.
When array is accessed with direct user input as index (0-based indexing)
Subtract 1 from user input when accessing array (convert to 1-based indexing)
KLEE can more easily generate valid test cases when input values start from 1 rather than 0, avoiding edge cases and improving constraint solving for array bounds
Before:
#include <stdio.h>
int main(int argc, char *argv[]){
int ary[]={0,0,2,0,1,0,1,0,0,1,0,1,0};
int x, y;
scanf("%d %d", &x, &y);
printf("%s", ary[x]==ary[y]?"Yes":"No");
return 0;
}
After:
#include <stdio.h>
int main(void){
int a,b,g[12]={1,3,1,2,1,2,1,1,2,1,2,1};
scanf("%d%d",&a,&b);
printf("%s\n",(g[a-1]==g[b-1])? "Yes":"No");
return 0;
}
3ca6b8c2