Rust-GCC / Rust-GCC/gccrs

Check for GCC -Warray-bounds checking that LLVM has

Open
#56 1 comment 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.