Bug 27120

Summary: Should warn about uninitialized use of variable array element
Product: gcc Reporter: Richard Biener <rguenth>
Component: cAssignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: enhancement CC: dominiq, gcc-bugs, P.Schaffnit
Priority: P3 Keywords: diagnostic
Version: 4.2.0   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2006-04-30 07:47:20
Bug Depends on:    
Bug Blocks: 10138, 24639    

Description Richard Biener 2006-04-11 15:56:49 UTC
int foo(int i)
{
  char buffer[10];
  return buffer[i];
}

does not warn about the use of uninitialized array buffer.  While

int foo(int i)
{
  char buffer[10];
  return buffer[2];
}

does.  Likewise for C++.
Comment 1 Andrew Pinski 2006-04-11 17:30:43 UTC
Related to PR 10138.
Comment 2 Andrew Pinski 2006-04-30 07:47:20 UTC
(In reply to comment #0)
[first testcase using nonconstant index]
> 
> does not warn about the use of uninitialized array buffer.  While
> 
[second testcase using constant index]
> 
> does.  Likewise for C++.

In the second example, SRA works on the array, scalarizes the array which allows for the current initialization warning to happen.  Now maybe we should do the uninitialization  warning in the front-end.
Comment 3 Francois-Xavier Coudert 2009-03-28 13:39:48 UTC
*** Bug 35234 has been marked as a duplicate of this bug. ***