This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Bogus warning caused by exception statement
- To: egcs-bugs at cygnus dot com
- Subject: Bogus warning caused by exception statement
- From: "C. van Reeuwijk" <C dot vanReeuwijk at twi dot tudelft dot nl>
- Date: Mon, 5 Jan 1998 17:21:30 +0100
- Organization: Delft University of Technology
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