[Bug middle-end/44069] [4.5 Regression] optimization bug initializing from cast array
--- Comment #5 from rguenth at gcc dot gnu dot org 2010-05-12 20:16 --- So, the issue is that the loop copying vals to m looks like : D.21310_23 = r_22 * 4; D.21309_25 = D.21310_23 + c_24; D.21308_26 = (long unsigned int) D.21309_25; D.21305_29 = vals[0][D.21308_26]; m.m[D.21309_25] = D.21305_29; c_30 = c_24 + 1; : # c_24 = PHI if (c_24 <= 3) goto ; else goto ; : r_31 = r_22 + 1; : # r_22 = PHI <0(2), r_31(5)> if (r_22 <= 3) goto ; else goto ; : # c_32 = PHI <0(6)> goto ; where vals[0][D.21308_26] does not represent a use of vals[i][j] with i > 0. This is because get_ref_base_and_extent restricts the valid extent of D.21308_26 to 3. Note that the issue is exposed by re-constructing an array-reference from the pointer access in the inlined constructor. After inlining into main() we have : D.21310_23 = r_22 * 4; D.21309_25 = D.21310_23 + c_24; D.21308_26 = (long unsigned int) D.21309_25; D.21307_27 = D.21308_26 * 8; D.21306_28 = &vals[0][D.21308_26]; D.21305_29 = *D.21306_28; m.m[D.21309_25] = D.21305_29; c_30 = c_24 + 1; from the non-inlined variant : D.21286_7 = r_1 * 4; D.21287_8 = D.21286_7 + c_2; D.21286_9 = r_1 * 4; D.21287_10 = D.21286_9 + c_2; D.21288_11 = (long unsigned int) D.21287_10; D.21289_12 = D.21288_11 * 8; D.21290_14 = arr_13(D) + D.21289_12; D.21291_15 = *D.21290_14; this_16(D)->m[D.21287_10] = D.21291_15; c_17 = c_2 + 1; -- rguenth at gcc dot gnu dot org changed: What|Removed |Added Component|c++ |middle-end Keywords||wrong-code Summary|optimization bug|[4.5 Regression] |initializing from cast array|optimization bug ||initializing from cast array Target Milestone|--- |4.5.1 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44069
[Bug middle-end/44069] [4.5 Regression] optimization bug initializing from cast array
--- Comment #9 from rguenth at gcc dot gnu dot org 2010-05-25 15:53 --- Fixed for 4.6 sofar. -- rguenth at gcc dot gnu dot org changed: What|Removed |Added Known to work||4.6.0 Summary|[4.5/4.6 Regression]|[4.5 Regression] |optimization bug|optimization bug |initializing from cast array|initializing from cast array http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44069
[Bug middle-end/44069] [4.5 Regression] optimization bug initializing from cast array
--- Comment #10 from rguenth at gcc dot gnu dot org 2010-05-26 11:44 --- Subject: Bug 44069 Author: rguenth Date: Wed May 26 11:44:44 2010 New Revision: 159865 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=159865 Log: 2010-05-26 Richard Guenther PR middle-end/44069 * tree-ssa-ccp.c (maybe_fold_stmt_addition): Avoid generating out-of-bounds array accesses. * g++.dg/torture/pr44069.C: New testcase. Added: branches/gcc-4_5-branch/gcc/testsuite/g++.dg/torture/pr44069.C Modified: branches/gcc-4_5-branch/gcc/ChangeLog branches/gcc-4_5-branch/gcc/testsuite/ChangeLog branches/gcc-4_5-branch/gcc/tree-ssa-ccp.c -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44069
[Bug middle-end/44069] [4.5 Regression] optimization bug initializing from cast array
--- Comment #11 from rguenth at gcc dot gnu dot org 2010-05-26 11:46 --- Fixed. -- rguenth at gcc dot gnu dot org changed: What|Removed |Added Status|ASSIGNED|RESOLVED Known to fail||4.5.0 Known to work|4.6.0 |4.5.1 4.6.0 Resolution||FIXED http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44069