GCC 2.95.2 -- warning where there is no reason for one

Denis Vakatov vakatov@peony.nlm.nih.gov
Tue Apr 11 15:31:00 GMT 2000


// By Denis Vakatov, NCBI  (vakatov@ncbi.nlm.nih.gov)
//
// GNU C/C++ Compiler ("-Wall -O" only):
//   issues a warning where there is no reason for one;
//
// $ c++ --version
// 2.95.2
// $ uname -a
// SunOS peony 5.7 Generic_106541-08 sun4u sparc SUNW,Ultra-5_10
//
// $ c++ -c  -Wall -O uu.cpp
// uu.cpp: In function `void f(EMy)':
// uu.cpp:30: warning: `int i' might be used uninitialized in this
function
//
// $ gcc -c  -Wall -O uu.cpp
// uu.cpp: In function `void f(EMy)':
// uu.cpp:30: warning: `int i' might be used uninitialized in this
function


typedef enum {
    eMy_1,
    eMy_2
} EMy;


extern void g(int);

void f(EMy e)
{
    int i;

    switch ( e ) {
    case eMy_1:
        i = 1;
        break;
    case eMy_2:
        i = 2;
        break;
    }

    // Although I have obviously exhausted all legitimate variants of
    // enumerator "EMy e" in the switch, however I still get this
warning:
    //
    // uu.cpp:30: warning: `int i' might be used uninitialized in this
function
    g(i);
}




More information about the Gcc-bugs mailing list