Bug 27120 - Should warn about uninitialized use of variable array element
Summary: Should warn about uninitialized use of variable array element
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.2.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
: 35234 (view as bug list)
Depends on:
Blocks: 10138 Wuninitialized
  Show dependency treegraph
 
Reported: 2006-04-11 15:56 UTC by Richard Biener
Modified: 2009-03-28 13:39 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-04-30 07:47:20


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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. ***