[Bug c/58101] New: Wrong out-of-bounds warning under -Os

2013-08-07 Thread llozano at google dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58101

Bug ID: 58101
   Summary: Wrong out-of-bounds warning under -Os
   Product: gcc
   Version: 4.8.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: llozano at google dot com

The following test case generates a wrong "out-of-bounds" warning. 
This problem only happens under -Os

gcc test.i -c -Os -Werror -Wall

 In function ‘rcu_init_lal’:
/home/llozano/trash/min_rcutree.i:17:13: error: array subscript is above array
bounds [-Werror=array-bounds]
   rsp->level[i] = rsp->level[i - 1] + rsp->levelcnt[i - 1];

rcu_num_levels is never larger than 1. So the code inside the loop is never
executed. 

test.i:
---
extern int rcu_num_lvls;
int rcu_num_lvls = 1;

struct rcu_node {
};

struct rcu_state {
 struct rcu_node *level[1];
 int levelcnt[4 + 1];
};

void rcu_init_lal(struct rcu_state *rsp)
{
 int i;

 for (i = 1; i < rcu_num_lvls; i++)
  rsp->level[i] = rsp->level[i - 1] + rsp->levelcnt[i - 1];
}

[Bug middle-end/58101] Wrong out-of-bounds warning under -Os

2013-08-07 Thread llozano at google dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58101

Luis A Lozano  changed:

   What|Removed |Added

   Severity|normal  |major

--- Comment #1 from Luis A Lozano  ---
Raising priority of this issue. 
This problem was found while build the ChromOS linux kernel. 
Most probably this will be found by other platfroms using the linux kernel.


[Bug middle-end/58101] Wrong out-of-bounds warning under -Os

2013-08-08 Thread llozano at google dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58101

--- Comment #3 from Luis A Lozano  ---
(In reply to Marek Polacek from comment #2)
> Perhaps a dup of PR41847.  Fails even with -O2, -O3, -Ofast, no only -Os. 
> -fno-tree-vrp makes it go away...

I dont think it is a duplicate of this issue. 
This problem does not happen with GCC 4.7.2