Check for GCC -Warray-bounds checking that LLVM has
Open
Nobody has claimed this yet.
enhancement
GCC
important
- Dominant language
- C++
- Stars
- 2.9k
- Forks
- 231
- Avg merge
- 19h 55m
- Merged PRs (30d)
- 67
Description
example:
int main(int argc, char **argv) {
int array[5] = {1,2,3,4,5};
int x = array[10];
return 0;
}
Compiling with GCC-master:
philbert@philbert-beast {~/workspace/gccrs-build} $ gcc -g -O0 -Wall test.c -o test
test.c: In function ‘main’:
test.c:4:9: warning: unused variable ‘x’ [-Wunused-variable]
4 | int x = array[10];
| ^
Compiling with clang:
philbert@philbert-beast {~/workspace/gccrs-build} $ clang -g -O0 -Wall test.c -o test
test.c:4:9: warning: unused variable 'x' [-Wunused-variable]
int x = array[10];
^
test.c:4:13: warning: array index 10 is past the end of the array (which contains 5 elements) [-Warray-bounds]
int x = array[10];
^ ~~
test.c:3:5: note: array 'array' declared here
int array[5] = {1,2,3,4,5};
^
2 warnings generated.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the standalone C example with GCC and Clang using the commands and source shown in the issue, then locate the compiler diagnostics and array-bounds checking implementation. Done means GCC reports an equivalent out-of-bounds warning for the example; the issue names no source files or tests to begin with.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100