This is the mail archive of the gcc-bugs@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]

incorrect warning message



gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)

SunOS 4.1.4 and Solaris 5.6

Command line:  gcc -O2 -c -Wall i.c

The incorrect warning is :

i.c: In function `img_hdis':
i.c:36: warning: `index' might be used uninitialized in this function

The source file is:

----------------------------------cut here-----------------------------------

int line_index[2][2]={{0,0},{0,0}};


enum IMAGE { NORM, HOLESCAN, ERCREFSCAN, AR0, AR3, ERCCADSCAN, ALL_DISKS, 
    	     HOLE_INSPECTION, REGSCAN };

extern void connect_elist(int);

__inline__
static void 
analyze_image(int cam, int index)
{
    switch (cam) {
	case ALL_DISKS:
	case ERCREFSCAN:
	case ERCCADSCAN:
	case REGSCAN:
	case NORM:
	connect_elist(index);
	break;

      default:
	exit(0);
    }
    return;
}

void 
img_hdis()
{
    int cam;

    for (cam = 0; cam < 7 ; cam++) {
	analyze_image(cam, line_index[0][cam]);
    }
}
----------------------------------cut here-----------------------------------

The message isn't produced with the -O option.  Changing only a little 
bit of the code causes the message to disappear, e.g., eliminate the
for loop in 'img_hdis()', or eliminate the case label 'All_DISKS', or
any of the case labels before the call to 'connect_elist()'.


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