The follwoing code generates warning
"warning: 'i' may be used uninitialized in this function"
Code is compiled with "g++ -O1 -Wall -c file.cpp -o file.o"
on x86_64 Fedora Core 6 (2.6.22.9-61.fc6)
with gcc version 4.1.2 20070626 (Red Hat 4.1.2-13)
Changing code in almost any way (like removing destructor) disables the
warning.
class ObjBase {
public:
virtual ~ObjBase() {}
};
class Obj : public ObjBase {
int _c;
public:
Obj(int c) : _c(c){};
};
int _Find(const Obj& key);
inline bool Find(const Obj& key, int& v)
{
static bool flag=true;
if (!flag) {
return false;
}
v=_Find(key);
return true;
}
int f() {
int i;
if (Find(0, i)) {
return i;
}
return 0;
}
int _Find(const Obj& key){return 0;}
--
Summary: false warning: 'variable' may be used uninitialized in
this function
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: paskhaver at yahoo dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36297