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: [email protected]
ReportedBy: [email protected]
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;
}