http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48414
Summary: Missing "uninitialized" warning in simple switch
Product: gcc
Version: 4.5.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: [email protected]
ReportedBy: [email protected]
Compiling the following code does not produce any warning, even if the "ret"
variable would be used uninitialized in most cases:
#include <stdio.h>
int main(void)
{
int ret;
printf("Input something: ");
fflush(stdout);
int c = getchar();
switch (c) {
case 'a':
ret = 0;
break;
default:
/* ret still uninitialized. */
break;
}
return ret;
}
Compiled with "gcc -Wall -o uninitialized uninitialized.c" under GCC 4.5.2.