From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17770 invoked by alias); 22 May 2008 07:45:01 -0000 Received: (qmail 17519 invoked by uid 48); 22 May 2008 07:44:19 -0000 Date: Thu, 22 May 2008 07:45:00 -0000 Subject: [Bug c++/36297] New: false warning: 'variable' may be used uninitialized in this function X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "paskhaver at yahoo dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2008-05/txt/msg01683.txt.bz2 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