http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55529
--- Comment #4 from Markus Trippelsdorf <markus at trippelsdorf dot de> 2012-11-29 13:16:08 UTC --- The testcase was derived from the Linux kernel: CC kernel/rcutree.o kernel/rcutree.c: In function ‘rcu_init_one’: kernel/rcutree.c:2850:13: warning: array subscript is above array bounds [-Warray-bounds] rsp->level[i] = rsp->level[i - 1] + rsp->levelcnt[i - 1]; ^ 2849 for (i = 1; i < rcu_num_lvls; i++) 2850 rsp->level[i] = rsp->level[i - 1] + rsp->levelcnt[i - 1]; Where rcu_num_lvls=RCU_NUM_LVLS. From kernel/rcutree.h: 31 /* 32 * Define shape of hierarchy based on NR_CPUS, CONFIG_RCU_FANOUT, and 33 * CONFIG_RCU_FANOUT_LEAF. 34 * In theory, it should be possible to add more levels straightforwardly. 35 * In practice, this did work well going from three levels to four. 36 * Of course, your mileage may vary. 37 */ 38 #define MAX_RCU_LVLS 4 39 #define RCU_FANOUT_1 (CONFIG_RCU_FANOUT_LEAF) 40 #define RCU_FANOUT_2 (RCU_FANOUT_1 * CONFIG_RCU_FANOUT) 41 #define RCU_FANOUT_3 (RCU_FANOUT_2 * CONFIG_RCU_FANOUT) 42 #define RCU_FANOUT_4 (RCU_FANOUT_3 * CONFIG_RCU_FANOUT) 43 44 #if NR_CPUS <= RCU_FANOUT_1 45 # define RCU_NUM_LVLS 1 46 # define NUM_RCU_LVL_0 1 47 # define NUM_RCU_LVL_1 (NR_CPUS) 48 # define NUM_RCU_LVL_2 0 49 # define NUM_RCU_LVL_3 0 50 # define NUM_RCU_LVL_4 0 51 #elif NR_CPUS <= RCU_FANOUT_2 52 # define RCU_NUM_LVLS 2 53 # define NUM_RCU_LVL_0 1 54 # define NUM_RCU_LVL_1 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_1) 55 # define NUM_RCU_LVL_2 (NR_CPUS) 56 # define NUM_RCU_LVL_3 0 57 # define NUM_RCU_LVL_4 0 58 #elif NR_CPUS <= RCU_FANOUT_3 59 # define RCU_NUM_LVLS 3 60 # define NUM_RCU_LVL_0 1 61 # define NUM_RCU_LVL_1 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_2) 62 # define NUM_RCU_LVL_2 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_1) 63 # define NUM_RCU_LVL_3 (NR_CPUS) 64 # define NUM_RCU_LVL_4 0 65 #elif NR_CPUS <= RCU_FANOUT_4 66 # define RCU_NUM_LVLS 4 67 # define NUM_RCU_LVL_0 1 68 # define NUM_RCU_LVL_1 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_3) 69 # define NUM_RCU_LVL_2 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_2) 70 # define NUM_RCU_LVL_3 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_1) 71 # define NUM_RCU_LVL_4 (NR_CPUS) 72 #else 73 # error "CONFIG_RCU_FANOUT insufficient for NR_CPUS" 74 #endif /* #if (NR_CPUS) <= RCU_FANOUT_1 */