https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61346
Bug ID: 61346 Summary: VRP chooses bad bounds for variable Product: gcc Version: 4.10.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: ian at airs dot com CC: cmang at google dot com The attached file, which is a Go test case converted to C code, should compile and run without error. It works with GCC 4.6.3 and GCC 4.9 branch with and without optimization. It works with mainline with -O0 and -O1. It fails with mainline with -O2. I think the problem is in the VRP pass. I see this in 067.vrp1: i_3: [data$len_58, 9223372036854775806] EQUIVALENCES: { i_65 } (1 elements) This is flat out wrong, as inspection of 066.mergephi2 shows that the ideally correct range of i_3 should be something like [0, data$len_58]. What's particularly odd is that i_3 is even set to i_1, and the range of i_1 is VARYING.