https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102996
Bug ID: 102996
Summary: No warning on use dereferencing of uninitialized point
in an array
Product: gcc
Version: 11.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: eyalroz1 at gmx dot com
Target Milestone: ---
Consider the following two functions:
void foo() {
int *as[2];
*(as[0])=1;
}
void bar() {
int i = 0;
int *as[2];
for(i=0;i<1;i++)
{
*(as[i])=i;
}
}
When compiling these with -Wall, we get warnings about the uninitialized use of
as in the first function, but not in the second one.
GodBolt: https://godbolt.org/z/Ta9fWYWs6
Inspired by this StackOverflow question:
https://stackoverflow.com/q/69764896/1593077