This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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];
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]