[Bug c/93849] New: 'Segmentation fault' in the special index for an array
haoxintu at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Feb 20 17:06:00 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93849
Bug ID: 93849
Summary: 'Segmentation fault' in the special index for an array
Product: gcc
Version: 5.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: haoxintu at gmail dot com
Target Milestone: ---
Hi, I am developing a random c generation tool to find c compiler bugs.
I found an interesting code that compiles successfully but get a "Segmentation
fault" result when executing it.
The c code is
void foo(int* a ) {
a[6]=1;
}
int main (int argc, char* argv[]) {
int array[] = {0};
foo(array);
return 0;
}
My compile command is "gcc test.cc" and it succeeds. Then I execute it using
"./a.out" but I got a "Segmentation fault" error.
I know we should initialize an array before using it. But the most interesting
thing is that only an index of 6 in an array can trigger the error, other index
is fine for execution.
I test the code in GCC 5.4.0 in ubuntu 16.04.
More information about the Gcc-bugs
mailing list