This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Flaw in method to detect uninitialized variables ?
- To: egcs at cygnus dot com
- Subject: Flaw in method to detect uninitialized variables ?
- From: Han Holl <jeholl at euronet dot nl>
- Date: Thu, 12 Feb 1998 11:54:14 +0100 (MET)
void f(int a, const char *s)
{
int c, count = 0;
while (count < a && (c = *s++) != 0) {
if (c == 8)
break;
count++;
}
}
void g(int a, const char *s)
{
int c, count = 0;
while (count++ < a && (c = *s++) != 0) {
if (c == 8)
break;
}
}
/*
specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnulibc1/egcs-2.90.23/specs
gcc version egcs-2.90.23 980102 (egcs-1.0.1 release)
Compile with -c -O -Wuninitialized , and you get:
try7.C: In function `void g(int, const char *)':
try7.C:14: warning: `int c' might be used uninitialized in this function
Isn't that interesting ?
Regards,
Han Holl
*/