Bug 12651 - Able to use a variable before it is defined
Summary: Able to use a variable before it is defined
Status: RESOLVED DUPLICATE of bug 10538
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.2
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-10-16 21:42 UTC by Erick Tryzelaar
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Erick Tryzelaar 2003-10-16 21:42:41 UTC
int main ()
{
     int i = i + 5;

     return 0;
}

compiles with:
gcc -Wall foo.c -o foo;

Is valid code. This appears to work with any variable.
I think there should be a warning, or compile error to prevent this from occuring.
Comment 1 Andrew Pinski 2003-10-16 21:46:28 UTC
This is a already fixed on the mainline by warning that the variable is uninitialized.
This is a dup of bug 10538.

*** This bug has been marked as a duplicate of 10538 ***