http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60957
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Status|NEW |UNCONFIRMED
Ever confirmed|1 |0
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is not fully a bogus warning. The warning is true if xxx._enabled is
false and bar returns something which is > 8.
Here is a shorter testcase:
extern bool foobar(const unsigned int);
extern void foo (void);
extern void bar2(bool *enabled, unsigned int old_width)
{
static const unsigned int size_map[] = { 0, 1, 2, 0, 4, 0, 0, 0, 8};
if(old_width > 8)
if(*enabled)
foo ();
unsigned int size = size_map[old_width];
if(size == 0)
if(*enabled)
foo ();
if(foobar(size))
foo ();
}
We are transforming the above into:
extern bool foobar(const unsigned int);
extern void foo (void);
extern void bar2(bool *enabled, unsigned int old_width)
{
unsigned int size;
static const unsigned int size_map[] = { 0, 1, 2, 0, 4, 0, 0, 0, 8};
if(old_width > 8)
{
if(*enabled)
foo ();
else
{
size = size_map[old_width];
goto t;
}
}
size = size_map[old_width];
if(size == 0)
if(*enabled)
foo ();
t:
if(foobar(size))
foo ();
}
Which is correct and we are warning about the access under the else statement.