https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61456
Bug ID: 61456
Summary: Unnecesary "may be used uninitialized" warning
Product: gcc
Version: 4.10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: tmsriram at google dot com
This test case:
problem.cc
==========
int rand ();
class Funcs
{
public:
int *f1 ();
int *f2 ();
};
typedef decltype (&Funcs::f1) pfunc;
static int Set (Funcs * f, const pfunc & fp)
{
(f->*fp) ();
}
void
Foo ()
{
pfunc fp = &Funcs::f1;
if (rand ())
fp = &Funcs::f2;
Set (0, fp);
}
compiled with trunk compiler:
g++ ./problem.cc -O2 -std=c++0x -c -Werror=uninitialized
./problem.cc: In function ‘void Foo()’:
./problem.cc:13:15: error: ‘fp.int* (Funcs::* const)()::__delta’ is used
uninitialized in this function [-Werror=uninitialized]
(f->*fp) ();
^
./problem.cc:19:11: note: ‘fp.int* (Funcs::* const)()::__delta’ was declared
here
pfunc fp = &Funcs::f1
With -fdump-tree-all, the dce1 pass is deleting the statement:
fp.__delta = 0;
even though this is later used with the following gimple sequence:
_22 = fp.__delta;
_24 = (struct Funcs *) _22;
iftmp.2_25 (_24);