Summary: | [4.8/4.9 regression] Incorrect handling of sum over first dimension of a product of automatic arrays | ||
---|---|---|---|
Product: | gcc | Reporter: | Stephan Kramer <stephan.kramer> |
Component: | fortran | Assignee: | Mikael Morin <mikael> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | jakub, mikael, tkoenig |
Priority: | P4 | ||
Version: | 4.8.1 | ||
Target Milestone: | 4.8.2 | ||
URL: | http://gcc.gnu.org/ml/fortran/2013-08/msg00059.html | ||
Host: | Target: | ||
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | 2013-07-03 00:00:00 | |
Attachments: | Patch moving the preliminary code before the outermost loop. |
Description
Stephan Kramer
2013-07-03 12:55:44 UTC
Confirmed. It appeared between revision 190090 (2012-08-02: OK) and 190271 (2012-08-09: wrong bounds). Valgrind reports ==70092== Invalid write of size 4 ==70092== at 0x100000DD1: func.1887 (pr57798.f90:12) ==70092== by 0x100000C32: sub.1867 (pr57798.f90:21) ==70092== by 0x100000D2F: MAIN__ (pr57798.f90:4) ==70092== by 0x100000E1A: main (pr57798.f90:4) ==70092== Address 0x100440480 is 0 bytes inside a block of size 1 alloc'd ==70092== at 0x100012679: malloc (vg_replace_malloc.c:266) ==70092== by 0x100000C0B: sub.1867 (pr57798.f90:21) ==70092== by 0x100000D2F: MAIN__ (pr57798.f90:4) ==70092== by 0x100000E1A: main (pr57798.f90:4) Mikael, this seems to be your area of expertise. Do you have any idea? (In reply to Thomas Koenig from comment #2) > Mikael, > > this seems to be your area of expertise. Do you have any idea? Hmm, in the dump, D.1917 is initialized to late, just before the inner loop inside the outer loop, but the first use comes before the outer loop. I'm having a look. Created attachment 30677 [details] Patch moving the preliminary code before the outermost loop. I suppose the regression appeared at r190097. I'm the author, but I think the bug was just latent before. However, as I'm the one who introduced nested loops with sum, I'm the culprit in any case. :-( The patch above (against 4.9-20130715) fixes the problem here. Patch submitted: http://gcc.gnu.org/ml/fortran/2013-08/msg00059.html Author: mikael Date: Fri Aug 23 17:49:39 2013 New Revision: 201947 URL: http://gcc.gnu.org/viewcvs?rev=201947&root=gcc&view=rev Log: fortran/ PR fortran/57798 * trans-array.c (gfc_conv_ss_startstride, set_loop_bounds, gfc_set_delta): Generate preliminary code before the outermost loop. testsuite/ PR fortran/57798 * gfortran.dg/inline_sum_5.f90: New. Added: trunk/gcc/testsuite/gfortran.dg/inline_sum_5.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/trans-array.c trunk/gcc/testsuite/ChangeLog Author: mikael Date: Sat Aug 24 12:46:17 2013 New Revision: 201966 URL: http://gcc.gnu.org/viewcvs?rev=201966&root=gcc&view=rev Log: fortran/ PR fortran/57798 * trans-array.c (gfc_conv_ss_startstride, set_loop_bounds, gfc_set_delta): Generate preliminary code before the outermost loop. testsuite/ PR fortran/57798 * gfortran.dg/inline_sum_5.f90: New. Added: branches/gcc-4_8-branch/gcc/testsuite/gfortran.dg/inline_sum_5.f90 Modified: branches/gcc-4_8-branch/gcc/fortran/ChangeLog branches/gcc-4_8-branch/gcc/fortran/trans-array.c branches/gcc-4_8-branch/gcc/testsuite/ChangeLog Fixed for 4.8.2 and 4.9.0 |