public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/60717] New: Wrong code with recursive procedure with unlimited polymorphic dummy argument
@ 2014-03-31 8:53 vladimir.fuka at gmail dot com
2014-03-31 12:22 ` [Bug fortran/60717] " pault at gcc dot gnu.org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: vladimir.fuka at gmail dot com @ 2014-03-31 8:53 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60717
Bug ID: 60717
Summary: Wrong code with recursive procedure with unlimited
polymorphic dummy argument
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: vladimir.fuka at gmail dot com
reported on comp.lang.fortran by Thomas Schnurrenberger
The output of the two parts of the following program should be the same, as
they are with some other compilers (tested with ifort 14). The output with 4.8
and 4.9 is:
Output of show_real:
0. 1. 2. 3. 4. 5.
0.
1. 2. 3. 4. 5.
1.
2. 3. 4. 5.
2.
3. 4. 5.
3.
4. 5.
4.
5.
5.
Output of show_generic:
0. 1. 2. 3. 4. 5.
0.
1. 2. 3. 4. 5.
2.
2. 3. 4. 5.
3.
3. 4. 5.
4.
4. 5.
5.
5.
0.
module m
!
implicit none
!
contains
!
recursive subroutine show_real(a)
real, intent(in) :: a(:)
!
if (size(a) > 0) then
print '(10f5.0)', a
print '(10f5.0)', a(1)
call show_real(a(2:))
end if
return
end subroutine show_real
!
recursive subroutine show_generic(a)
class(*), intent(in) :: a(:)
!
if (size(a) > 0) then
select type (a)
type is (real)
print '(10f5.0)', a
print '(10f5.0)', a(1)
end select
call show_generic(a(2:))
end if
return
end subroutine show_generic
!
end module m
program test
!
use :: m
!
implicit none
!
real :: array(1:6) = (/ 0, 1, 2, 3, 4, 5 /)
!
print *, 'Output of show_real:'
call show_real(array)
print *, 'Output of show_generic:'
call show_generic(array)
!
end program test
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/60717] Wrong code with recursive procedure with unlimited polymorphic dummy argument
2014-03-31 8:53 [Bug fortran/60717] New: Wrong code with recursive procedure with unlimited polymorphic dummy argument vladimir.fuka at gmail dot com
@ 2014-03-31 12:22 ` pault at gcc dot gnu.org
2014-04-01 4:42 ` pault at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu.org @ 2014-03-31 12:22 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60717
Paul Thomas <pault at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-03-31
CC| |pault at gcc dot gnu.org
Assignee|unassigned at gcc dot gnu.org |pault at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from Paul Thomas <pault at gcc dot gnu.org> ---
Confirmed. You beat me to it by about 30 minutes, Vladimir!
The problem is the recursive call within 'show_generic':
D.3571 = a->_data.dim[0].ubound;
parm.2.dtype = 345;
D.3575 = a->_data.dim[0].stride;
parm.2.dim[0].lbound = 1;
parm.2.dim[0].ubound = D.3571 + -1;
parm.2.dim[0].stride = NON_LVALUE_EXPR <D.3575>;
parm.2.data = a->_data.data + (sizetype) (a->_vptr->_size *
NON_LVALUE_EXPR <D.3575>);
parm.2.offset = 0;
class.3._data = VIEW_CONVERT_EXPR<struct array1_unknown>(parm.2);
class.3._vptr = a->_vptr;
show_generic (&class.3);
The offset is 0, whereas it should be -1.
The call to 'show_generic' from the main program is done correctly:
parm.17.dtype = 281;
parm.17.dim[0].lbound = 1;
parm.17.dim[0].ubound = 6;
parm.17.dim[0].stride = 1;
parm.17.data = (void *) &array[0];
parm.17.offset = -1;
class.16._data = parm.17;
show_generic (&class.16);
This tells us exactly where the problem is.
I am taking it.
Paul
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/60717] Wrong code with recursive procedure with unlimited polymorphic dummy argument
2014-03-31 8:53 [Bug fortran/60717] New: Wrong code with recursive procedure with unlimited polymorphic dummy argument vladimir.fuka at gmail dot com
2014-03-31 12:22 ` [Bug fortran/60717] " pault at gcc dot gnu.org
@ 2014-04-01 4:42 ` pault at gcc dot gnu.org
2014-04-03 7:53 ` vladimir.fuka at gmail dot com
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu.org @ 2014-04-01 4:42 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60717
--- Comment #2 from Paul Thomas <pault at gcc dot gnu.org> ---
Created attachment 32509
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32509&action=edit
Patch for the PR
This patch bootstraps and regtests OK. I will tidy it up a bit tonight.
I also wish to check if it can be used to clean up:
trans-expr.c(gfc_trans_alloc_subarray_assign)
trans-expr.c(gfc_trans_pointer_assign)
trans-expr.c(fncall_realloc_result)
trans-array.c(trans_associate_var)
each of which contains calculation of the offset.
Paul
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/60717] Wrong code with recursive procedure with unlimited polymorphic dummy argument
2014-03-31 8:53 [Bug fortran/60717] New: Wrong code with recursive procedure with unlimited polymorphic dummy argument vladimir.fuka at gmail dot com
2014-03-31 12:22 ` [Bug fortran/60717] " pault at gcc dot gnu.org
2014-04-01 4:42 ` pault at gcc dot gnu.org
@ 2014-04-03 7:53 ` vladimir.fuka at gmail dot com
2014-04-03 8:28 ` dominiq at lps dot ens.fr
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: vladimir.fuka at gmail dot com @ 2014-04-03 7:53 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60717
--- Comment #3 from Vladimir Fuka <vladimir.fuka at gmail dot com> ---
Could there be a connection http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58085 ?
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/60717] Wrong code with recursive procedure with unlimited polymorphic dummy argument
2014-03-31 8:53 [Bug fortran/60717] New: Wrong code with recursive procedure with unlimited polymorphic dummy argument vladimir.fuka at gmail dot com
` (2 preceding siblings ...)
2014-04-03 7:53 ` vladimir.fuka at gmail dot com
@ 2014-04-03 8:28 ` dominiq at lps dot ens.fr
2014-04-13 11:56 ` pault at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-04-03 8:28 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60717
--- Comment #4 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> Could there be a connection http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58085 ?
May be, but pr58085 is not fixed by the patch in comment 2 (submitted at
http://gcc.gnu.org/ml/fortran/2014-04/msg00005.html).
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/60717] Wrong code with recursive procedure with unlimited polymorphic dummy argument
2014-03-31 8:53 [Bug fortran/60717] New: Wrong code with recursive procedure with unlimited polymorphic dummy argument vladimir.fuka at gmail dot com
` (3 preceding siblings ...)
2014-04-03 8:28 ` dominiq at lps dot ens.fr
@ 2014-04-13 11:56 ` pault at gcc dot gnu.org
2014-04-13 11:59 ` pault at gcc dot gnu.org
2015-10-18 10:56 ` pault at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu.org @ 2014-04-13 11:56 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60717
--- Comment #6 from Paul Thomas <pault at gcc dot gnu.org> ---
Author: pault
Date: Sun Apr 13 11:55:49 2014
New Revision: 209346
URL: http://gcc.gnu.org/viewcvs?rev=209346&root=gcc&view=rev
Log:
2014-04-13 Paul Thomas <pault@gcc.gnu.org>
PR fortran/58085
PR fortran/60717
* trans.h: Add 'use_offset' bitfield to gfc_se.
* trans-array.c (gfc_conv_expr_descriptor): Use 'use_offset'
as a trigger to unconditionally recalculate the offset for
array slices and constant arrays.
trans-expr.c (gfc_conv_intrinsic_to_class): Use it.
trans-stmt.c (trans_associate_var): Ditto.
(gfc_conv_procedure_call): Ditto.
2014-04-13 Paul Thomas <pault@gcc.gnu.org>
PR fortran/60717
* gfortran.dg/unlimited_polymorphic_17.f90: New test.
PR fortran/58085
* gfortran.dg/associate_15.f90: New test.
Added:
branches/gcc-4_9-branch/gcc/testsuite/gfortran.dg/associate_15.f90
branches/gcc-4_9-branch/gcc/testsuite/gfortran.dg/unlimited_polymorphic_17.f90
Modified:
branches/gcc-4_9-branch/gcc/fortran/ChangeLog
branches/gcc-4_9-branch/gcc/fortran/trans-array.c
branches/gcc-4_9-branch/gcc/fortran/trans-expr.c
branches/gcc-4_9-branch/gcc/fortran/trans-stmt.c
branches/gcc-4_9-branch/gcc/fortran/trans.h
branches/gcc-4_9-branch/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/60717] Wrong code with recursive procedure with unlimited polymorphic dummy argument
2014-03-31 8:53 [Bug fortran/60717] New: Wrong code with recursive procedure with unlimited polymorphic dummy argument vladimir.fuka at gmail dot com
` (4 preceding siblings ...)
2014-04-13 11:56 ` pault at gcc dot gnu.org
@ 2014-04-13 11:59 ` pault at gcc dot gnu.org
2015-10-18 10:56 ` pault at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu.org @ 2014-04-13 11:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60717
--- Comment #7 from Paul Thomas <pault at gcc dot gnu.org> ---
Author: pault
Date: Sun Apr 13 11:58:55 2014
New Revision: 209347
URL: http://gcc.gnu.org/viewcvs?rev=209347&root=gcc&view=rev
Log:
2014-04-13 Paul Thomas <pault@gcc.gnu.org>
PR fortran/58085
PR fortran/60717
* trans.h: Add 'use_offset' bitfield to gfc_se.
* trans-array.c (gfc_conv_expr_descriptor): Use 'use_offset'
as a trigger to unconditionally recalculate the offset for
array slices and constant arrays.
trans-expr.c (gfc_conv_intrinsic_to_class): Use it.
trans-stmt.c (trans_associate_var): Ditto.
(gfc_conv_procedure_call): Ditto.
2014-04-13 Paul Thomas <pault@gcc.gnu.org>
PR fortran/60717
* gfortran.dg/unlimited_polymorphic_17.f90: New test.
PR fortran/58085
* gfortran.dg/associate_15.f90: New test.
Added:
trunk/gcc/testsuite/gfortran.dg/associate_15.f90
trunk/gcc/testsuite/gfortran.dg/unlimited_polymorphic_17.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/trans-array.c
trunk/gcc/fortran/trans-expr.c
trunk/gcc/fortran/trans-stmt.c
trunk/gcc/fortran/trans.h
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/60717] Wrong code with recursive procedure with unlimited polymorphic dummy argument
2014-03-31 8:53 [Bug fortran/60717] New: Wrong code with recursive procedure with unlimited polymorphic dummy argument vladimir.fuka at gmail dot com
` (5 preceding siblings ...)
2014-04-13 11:59 ` pault at gcc dot gnu.org
@ 2015-10-18 10:56 ` pault at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu.org @ 2015-10-18 10:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60717
Paul Thomas <pault at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #8 from Paul Thomas <pault at gcc dot gnu.org> ---
It seems that I forgot to close this one.
Thanks for the report
Paul
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-10-18 10:56 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-31 8:53 [Bug fortran/60717] New: Wrong code with recursive procedure with unlimited polymorphic dummy argument vladimir.fuka at gmail dot com
2014-03-31 12:22 ` [Bug fortran/60717] " pault at gcc dot gnu.org
2014-04-01 4:42 ` pault at gcc dot gnu.org
2014-04-03 7:53 ` vladimir.fuka at gmail dot com
2014-04-03 8:28 ` dominiq at lps dot ens.fr
2014-04-13 11:56 ` pault at gcc dot gnu.org
2014-04-13 11:59 ` pault at gcc dot gnu.org
2015-10-18 10:56 ` pault at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).