[Bug middle-end/60957] [4.9/4.10 Regression] Bogus error: array subscript is above array bounds [-Werror=array-bounds]

2014-04-28 Thread law at redhat dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60957

Jeffrey A. Law law at redhat dot com changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 CC||law at redhat dot com
 Resolution|--- |INVALID

--- Comment #6 from Jeffrey A. Law law at redhat dot com ---
Agreed.  Nothing guards the reference to size_map[old_width].


[Bug middle-end/60957] [4.9/4.10 Regression] Bogus error: array subscript is above array bounds [-Werror=array-bounds]

2014-04-25 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60957

Richard Biener rguenth at gcc dot gnu.org changed:

   What|Removed |Added

   Target Milestone|--- |4.9.1

--- Comment #5 from Richard Biener rguenth at gcc dot gnu.org ---
Yeah, nothing guards the size_map access if !(old_width = 8).  I'd say this
report is invalid.

Triggered by more elaborate jump-threading, btw.


[Bug middle-end/60957] [4.9/4.10 Regression] Bogus error: array subscript is above array bounds [-Werror=array-bounds]

2014-04-24 Thread hjl.tools at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60957

H.J. Lu hjl.tools at gmail dot com changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2014-04-24
 CC||law at gcc dot gnu.org
  Component|c++ |middle-end
Version|unknown |4.9.0
 Ever confirmed|0   |1

--- Comment #1 from H.J. Lu hjl.tools at gmail dot com ---
It is caused by r205074.


[Bug middle-end/60957] [4.9/4.10 Regression] Bogus error: array subscript is above array bounds [-Werror=array-bounds]

2014-04-24 Thread pinskia at gcc dot gnu.org
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.


[Bug middle-end/60957] [4.9/4.10 Regression] Bogus error: array subscript is above array bounds [-Werror=array-bounds]

2014-04-24 Thread pinskia at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60957

--- Comment #3 from Andrew Pinski pinskia at gcc dot gnu.org ---
What source does this come from?


[Bug middle-end/60957] [4.9/4.10 Regression] Bogus error: array subscript is above array bounds [-Werror=array-bounds]

2014-04-24 Thread hjl.tools at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60957

--- Comment #4 from H.J. Lu hjl.tools at gmail dot com ---
(In reply to Andrew Pinski from comment #3)
 What source does this come from?

This comes from a real application.