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]

Bogus warning caused by exception statement


Hello,

If this has been reported before, I couldn't find it.

The following code generates a bogus warning:

=-=-=-=
$ cat t.cc
#include "stdio.h"

void writeNote() throw( int )
{
    printf( "hello world\n" );
    try { }
    catch( int ){ throw; }
}
=-=-=-=

The warning is:
=-=-=-=
$ g++ -c -O2 -W t.cc
t.cc: In function `void writeNote()':
t.cc:8: warning: `struct cp_eh_info * __exception_info' might be used uninitialized in this function
=-=-=-=

The code is shrunk to its minimum: the explicit exception declaration
for writeNote() is necessary, as is the printf() statement.

In other code I've seen similar bogus warnings about local variables
of the function; they were also caused by a try statement.

I use egcs 1.0:
=-=-=-=
$ g++ -v
Reading specs from /usr/local/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.90.21/specs
gcc version egcs-2.90.21 971202 (egcs-1.00 release)
=-=-=-=

BTW, if I leave out the catch() line, the compiler gets quite confused;
a more to-the-point error message would perhaps be nice.

-- 
Kees van Reeuwijk, Delft University of Technology
http://pds.twi.tudelft.nl/~reeuwijk


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