* [Bug fortran/38033] Bounds of a pointer/allocatable array not stabilized
2008-11-06 14:25 [Bug fortran/38033] New: Bounds of a pointer/allocatable array not stabilized pault at gcc dot gnu dot org
@ 2008-11-06 14:26 ` pault at gcc dot gnu dot org
2008-11-06 21:10 ` pault at gcc dot gnu dot org
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-11-06 14:26 UTC (permalink / raw)
To: gcc-bugs
--
pault at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |pault at gcc dot gnu dot org
|dot org |
Status|UNCONFIRMED |ASSIGNED
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2008-11-06 14:24:59
date| |
Summary|Bounds of a |Bounds of a
|pointer/allocatable array |pointer/allocatable array
|not stabilized |not stabilized
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38033
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/38033] Bounds of a pointer/allocatable array not stabilized
2008-11-06 14:25 [Bug fortran/38033] New: Bounds of a pointer/allocatable array not stabilized pault at gcc dot gnu dot org
2008-11-06 14:26 ` [Bug fortran/38033] " pault at gcc dot gnu dot org
@ 2008-11-06 21:10 ` pault at gcc dot gnu dot org
2008-11-07 14:01 ` pault at gcc dot gnu dot org
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-11-06 21:10 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pault at gcc dot gnu dot org 2008-11-06 21:09 -------
(In reply to comment #0)
Index: gcc/fortran/trans-array.c
===================================================================
--- gcc/fortran/trans-array.c (revision 141655)
+++ gcc/fortran/trans-array.c (working copy)
@@ -645,13 +645,16 @@
{
n = loop->order[dim];
if (n < loop->temp_dim)
- gcc_assert (integer_zerop (loop->from[n]));
+ gcc_assert (integer_zerop (loop->from[n]));
else
{
/* Callee allocated arrays may not have a known bound yet. */
if (loop->to[n])
- loop->to[n] = fold_build2 (MINUS_EXPR, gfc_array_index_type,
- loop->to[n], loop->from[n]);
+ {
+ tmp = fold_build2 (MINUS_EXPR, gfc_array_index_type,
+ loop->to[n], loop->from[n]);
+ loop->to[n] = gfc_evaluate_now (tmp, pre);
+ }
loop->from[n] = gfc_index_zero_node;
}
Removes the _gfortran_size0 calls from the loop but I have not yet located the
doubling up of calls here:
D.1551 = temp.offset;
D.1552 = &a;
D.1553 = (integer(kind=8)) (integer(kind=4)) _gfortran_size0 (D.1552);
D.1554 = &a;
D.1555 = (integer(kind=8)) (integer(kind=4)) _gfortran_size0 (D.1554) + -1;
atmp.1.dtype = 281;
atmp.1.dim[0].stride = 1;
atmp.1.dim[0].lbound = 0;
atmp.1.dim[0].ubound = D.1555;
D.1557 = D.1555 + 1 <= 0;
D.1558 = D.1555 + 1;
D.1559 = D.1557 ? 0 : D.1558 * 4;
if (D.1559 < 0)
{
_gfortran_runtime_error (&"Attempt to allocate a negative amount of
memory."[1]{lb: 1 sz: 1});
}
D.1560 = __builtin_malloc (MAX_EXPR <D.1559, 1>);
if (D.1560 == 0B)
{
_gfortran_os_error (&"Memory allocation failed"[1]{lb: 1 sz: 1});
}
D.1561 = D.1560;
atmp.1.data = D.1561;
atmp.1.offset = 0;
D.1563 = NON_LVALUE_EXPR <D.1548>;
{
integer(kind=8) D.1566;
integer(kind=8) D.1565;
integer(kind=8) S.2;
D.1565 = a.dim[0].stride;
D.1566 = temp.dim[0].stride;
S.2 = 0;
while (1)
{
if (S.2 > D.1555) goto L.1;
(*(real(kind=4)[0:] *) atmp.1.data)[S.2] = (*D.1546)[(S.2 + D.1563) *
D.1565 + D.1547];
S.2 = S.2 + 1;
}
L.1:;
S.2 = 0;
while (1)
{
if (S.2 > D.1555) goto L.2;
(*D.1550)[(S.2 + 1) * D.1566 + D.1551] = (*(real(kind=4)[0:] *)
atmp.1.data)[S.2];
S.2 = S.2 + 1;
}
L.2:;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38033
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/38033] Bounds of a pointer/allocatable array not stabilized
2008-11-06 14:25 [Bug fortran/38033] New: Bounds of a pointer/allocatable array not stabilized pault at gcc dot gnu dot org
2008-11-06 14:26 ` [Bug fortran/38033] " pault at gcc dot gnu dot org
2008-11-06 21:10 ` pault at gcc dot gnu dot org
@ 2008-11-07 14:01 ` pault at gcc dot gnu dot org
2008-11-13 15:03 ` pault at gcc dot gnu dot org
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-11-07 14:01 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pault at gcc dot gnu dot org 2008-11-07 13:59 -------
(In reply to comment #1)
> (In reply to comment #0)
> Removes the _gfortran_size0 calls from the loop but I have not yet located the
> doubling up of calls here:
>
> D.1551 = temp.offset;
> D.1552 = &a;
> D.1553 = (integer(kind=8)) (integer(kind=4)) _gfortran_size0 (D.1552);
> D.1554 = &a;
> D.1555 = (integer(kind=8)) (integer(kind=4)) _gfortran_size0 (D.1554) + -1
The second call and stabilization of &a comes from the patch in #1. The first
is from gfc_conv_section_startstride, after:
/* Similarly calculate the end. Although this is not used in the
scalarizer, it is needed when checking bounds and where the end
is an expression with side-effects. */
Thus, rather than using loop->to[n], we will probably have to detect
GFC_SS_SECTION && ss->data.info.end[n] and the use ss->data.info.start[n] and
ss->data.info.end[n].
I'm working on it!
Paul
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38033
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/38033] Bounds of a pointer/allocatable array not stabilized
2008-11-06 14:25 [Bug fortran/38033] New: Bounds of a pointer/allocatable array not stabilized pault at gcc dot gnu dot org
` (2 preceding siblings ...)
2008-11-07 14:01 ` pault at gcc dot gnu dot org
@ 2008-11-13 15:03 ` pault at gcc dot gnu dot org
2008-11-13 19:07 ` mikael at gcc dot gnu dot org
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-11-13 15:03 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from pault at gcc dot gnu dot org 2008-11-13 15:01 -------
Created an attachment (id=16662)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16662&action=view)
Patch for PR
This is not regtested yet but it fixes the testcase completely. Watch this
space!
Paul
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38033
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/38033] Bounds of a pointer/allocatable array not stabilized
2008-11-06 14:25 [Bug fortran/38033] New: Bounds of a pointer/allocatable array not stabilized pault at gcc dot gnu dot org
` (3 preceding siblings ...)
2008-11-13 15:03 ` pault at gcc dot gnu dot org
@ 2008-11-13 19:07 ` mikael at gcc dot gnu dot org
2008-11-14 11:17 ` pault at gcc dot gnu dot org
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: mikael at gcc dot gnu dot org @ 2008-11-13 19:07 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from mikael at gcc dot gnu dot org 2008-11-13 19:05 -------
Maybe we can drop gfc_conv_section_upper_bound completely.
It looks redundant with how info->end[n] is calculated in
gfc_conv_section_startstride.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38033
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/38033] Bounds of a pointer/allocatable array not stabilized
2008-11-06 14:25 [Bug fortran/38033] New: Bounds of a pointer/allocatable array not stabilized pault at gcc dot gnu dot org
` (4 preceding siblings ...)
2008-11-13 19:07 ` mikael at gcc dot gnu dot org
@ 2008-11-14 11:17 ` pault at gcc dot gnu dot org
2008-11-14 12:55 ` mikael at gcc dot gnu dot org
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-11-14 11:17 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from pault at gcc dot gnu dot org 2008-11-14 11:16 -------
Mikael,
(In reply to comment #4)
> Maybe we can drop gfc_conv_section_upper_bound completely.
> It looks redundant with how info->end[n] is calculated in
> gfc_conv_section_startstride.
>
I tried that and generated a load of regressions. I didn't analyse this but
stuck with the patch as is. I maybe will think about it some more but I am
inclined to put a TODO in there.
Thanks
Paul
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38033
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/38033] Bounds of a pointer/allocatable array not stabilized
2008-11-06 14:25 [Bug fortran/38033] New: Bounds of a pointer/allocatable array not stabilized pault at gcc dot gnu dot org
` (5 preceding siblings ...)
2008-11-14 11:17 ` pault at gcc dot gnu dot org
@ 2008-11-14 12:55 ` mikael at gcc dot gnu dot org
2008-11-14 18:05 ` pault at gcc dot gnu dot org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: mikael at gcc dot gnu dot org @ 2008-11-14 12:55 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from mikael at gcc dot gnu dot org 2008-11-14 12:54 -------
(In reply to comment #5)
> I tried that and generated a load of regressions.
Fine. Let's keep it as is then.
>
> Thanks
Thanks to you.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38033
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/38033] Bounds of a pointer/allocatable array not stabilized
2008-11-06 14:25 [Bug fortran/38033] New: Bounds of a pointer/allocatable array not stabilized pault at gcc dot gnu dot org
` (6 preceding siblings ...)
2008-11-14 12:55 ` mikael at gcc dot gnu dot org
@ 2008-11-14 18:05 ` pault at gcc dot gnu dot org
2008-11-14 18:41 ` pault at gcc dot gnu dot org
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-11-14 18:05 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from pault at gcc dot gnu dot org 2008-11-14 18:04 -------
Subject: Bug 38033
Author: pault
Date: Fri Nov 14 18:03:05 2008
New Revision: 141861
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141861
Log:
2008-10-14 Paul Thomas <pault@gcc.gnu.org>
PR fortran/38033
* trans-array.c (gfc_trans_create_temp_array): Stabilize the
'to' expression.
(gfc_conv_loop_setup): Use the end expression for the loop 'to'
if it is available.
2008-10-14 Paul Thomas <pault@gcc.gnu.org>
PR fortran/38033
* gfortran.dg/array_section_2.f90: New test.
Added:
trunk/gcc/testsuite/gfortran.dg/array_section_2.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/trans-array.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38033
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/38033] Bounds of a pointer/allocatable array not stabilized
2008-11-06 14:25 [Bug fortran/38033] New: Bounds of a pointer/allocatable array not stabilized pault at gcc dot gnu dot org
` (7 preceding siblings ...)
2008-11-14 18:05 ` pault at gcc dot gnu dot org
@ 2008-11-14 18:41 ` pault at gcc dot gnu dot org
2008-11-24 21:39 ` pault at gcc dot gnu dot org
2008-11-24 21:39 ` pault at gcc dot gnu dot org
10 siblings, 0 replies; 12+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-11-14 18:41 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from pault at gcc dot gnu dot org 2008-11-14 18:39 -------
Fixed on trunk
Paul
--
pault at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38033
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/38033] Bounds of a pointer/allocatable array not stabilized
2008-11-06 14:25 [Bug fortran/38033] New: Bounds of a pointer/allocatable array not stabilized pault at gcc dot gnu dot org
` (8 preceding siblings ...)
2008-11-14 18:41 ` pault at gcc dot gnu dot org
@ 2008-11-24 21:39 ` pault at gcc dot gnu dot org
2008-11-24 21:39 ` pault at gcc dot gnu dot org
10 siblings, 0 replies; 12+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-11-24 21:39 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from pault at gcc dot gnu dot org 2008-11-24 21:38 -------
Fixed on trunk and 4.3.
Thanks for the report.
Paul
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38033
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/38033] Bounds of a pointer/allocatable array not stabilized
2008-11-06 14:25 [Bug fortran/38033] New: Bounds of a pointer/allocatable array not stabilized pault at gcc dot gnu dot org
` (9 preceding siblings ...)
2008-11-24 21:39 ` pault at gcc dot gnu dot org
@ 2008-11-24 21:39 ` pault at gcc dot gnu dot org
10 siblings, 0 replies; 12+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-11-24 21:39 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from pault at gcc dot gnu dot org 2008-11-24 21:37 -------
Subject: Bug 38033
Author: pault
Date: Mon Nov 24 21:36:05 2008
New Revision: 142174
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142174
Log:
2008-11-24 Paul Thomas <pault@gcc.gnu.org>
PR fortran/38033
* trans-array.c (gfc_trans_create_temp_array): Stabilize the
'to' expression.
(gfc_conv_loop_setup): Use the end expression for the loop 'to'
if it is available.
2008-11-24 Paul Thomas <pault@gcc.gnu.org>
PR fortran/38033
* gfortran.dg/array_section_2.f90: New test.
Added:
branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/array_section_2.f90
Modified:
branches/gcc-4_3-branch/gcc/fortran/ChangeLog
branches/gcc-4_3-branch/gcc/fortran/trans-array.c
branches/gcc-4_3-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38033
^ permalink raw reply [flat|nested] 12+ messages in thread