This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: -Wall not detecting uninitialized variables


On Wed, Sep 07, 2011 at 05:36:50PM +0100, Andrew Haley wrote:
> On 09/07/2011 05:34 PM, sudhakar govindavajhala wrote:
> > #include <stdio.h>
> > 
> > int main() {
> >         int i;
> >         printf(" hi sud %d \n", i);
> >         return 0;
> > 
> > }
> 
> zebedee:~ $ gcc --version
> gcc (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4)
> 
> zebedee:~ $ gcc -Wall t.c
> t.c: In function 'main':
> t.c:5:15: warning: 'i' is used uninitialized in this function

gcc 4.1 warns if optimization is activated:
Jupiter:~ $ gcc-4.1 -Wall -O test.c
test.c: In function âmainâ:
test.c:5: warning: âiâ is used uninitialized in this function

Jupiter:~ $ gcc-4.1 --version
gcc-4.1 (GCC) 4.1.3 20080704 (prerelease) (Debian 4.1.2-29)

Axel


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]