This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/58101] New: Wrong out-of-bounds warning under -Os
- From: "llozano at google dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 07 Aug 2013 18:31:10 +0000
- Subject: [Bug c/58101] New: Wrong out-of-bounds warning under -Os
- Auto-submitted: auto-generated
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];
}