Bug 39113 - no warning that a variable may be used uninitialized
no warning that a variable may be used uninitialized
Status: RESOLVED DUPLICATE of bug 18501
Product: gcc
Classification: Unclassified
Component: c
4.3.2
: P3 normal
: ---
Assigned To: Not yet assigned to anyone
: diagnostic
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-02-05 20:49 UTC by David Hill
Modified: 2009-02-05 21:57 UTC (History)
12 users (show)

See Also:
Host: --host=x86_64-linux-gnu
Target: --target=x86_64-linux-gnu
Build: --build=x86_64-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments
.i file (24.73 KB, text/plain)
2009-02-05 20:51 UTC, David Hill
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Hill 2009-02-05 20:49:46 UTC
$gcc -O -Wextra -save-temps um3.c
$

um3.c

#include <stdio.h>

main()
{
char *J;

if (rand())
  J = NULL;

printf("\ntest %s\n",J);
}


In this example, J could be used uninitialized but the compiler is not giving that warning.
Comment 1 David Hill 2009-02-05 20:51:24 UTC
Created attachment 17252 [details]
.i file
Comment 2 David Hill 2009-02-05 21:04:03 UTC
Here is the gcc -v output if that is helpful

$ gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.3.2-1ubuntu12' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.3.2 (Ubuntu 4.3.2-1ubuntu12) 
Comment 3 David Hill 2009-02-05 21:48:20 UTC
Note that the warning is correctly reported in older versions of the compiler.

The following example is from gcc 3.2.3


$ gcc -O -W um3.c
um3.c: In function `main':
um3.c:5: warning: `J' might be used uninitialized in this function


$ gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux
Thread model: posix
gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-59)

$ cat um3.c
#include <stdio.h>

main()
{
char *J;

if (rand())
  J = NULL;

printf("\ntest %s\n",J);
}

Comment 4 Andrew Pinski 2009-02-05 21:57:12 UTC

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

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