[Bug c/56458] New: support for crash on invalid array access

wbrana at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Feb 26 11:41:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56458

             Bug #: 56458
           Summary: support for crash on invalid array access
    Classification: Unclassified
           Product: gcc
           Version: 4.7.3
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: wbrana@gmail.com


GCC could support command-line flag for at least C and C++, which would enable
checking of array access, which would increase security.
If wrong access is detected, process should crash, but following code returns
two zeros. 

#include <iostream>
using namespace std;

int array[5];

inline void crash() {
        int* v = 0;
        *v = 0;
}

int read1(int i) {
        return array[i];
}

int write1(int i) {
        return array[i] = 0;
}

int main(int i, char* argv[]) {
        cout << read1(i + 100) << endl;
        cout << write1(i + 100) << endl;
        return 0;
}



More information about the Gcc-bugs mailing list