This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/61456] New: Unnecesary "may be used uninitialized" warning
- From: "tmsriram at google dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 09 Jun 2014 18:36:47 +0000
- Subject: [Bug middle-end/61456] New: Unnecesary "may be used uninitialized" warning
- Auto-submitted: auto-generated
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);