This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/13959] New: un-init local variable detection enhancement request
- From: "d dot binderman at virgin dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 1 Feb 2004 14:18:03 -0000
- Subject: [Bug c++/13959] New: un-init local variable detection enhancement request
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
/*
The source code at the end of the file, causes g++ 3.3.2 to say nothing,
with the flag -c.
[dcb@localhost src]$ g++ -c qw.cc
[dcb@localhost src]$
When I compile with -g -O2 -Wall, I get a warning, but that only says
"might".
[dcb@localhost src]$ g++ -c -g -O2 -Wall qw.cc
qw.cc: In function `void g()':
qw.cc:6: warning: `int i' might be used uninitialized in this function
[dcb@localhost src]$
Suggest enhancement that I should get a warning message without needing
to use -g -O2 -Wall.
Suggest further that the warning message be improved to say something
stronger than "might".
Here is the Intel compiler doing what I want.
[dcb@localhost src]$ icc qw.cc
qw.cc(8): warning #592: variable "i" is used before its value is set
[dcb@localhost src]$
It seems to me that in the case where
1. an uninitialised local variable is declared
and
2. the first thing that happens to it is that it is read from
then a warning message should be produced.
This case is salted down from dozens of cases in Redhat Fedora Core 1.
*/
extern int f( int );
void g()
{
int i;
f( i);
}
--
Summary: un-init local variable detection enhancement request
Product: gcc
Version: 3.3.2
Status: UNCONFIRMED
Severity: enhancement
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: d dot binderman at virgin dot net
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13959