public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/52351] New: Wrong bounds when passing an array section to an intent-in pointer dummy
@ 2012-02-23 10:49 burnus at gcc dot gnu.org
2012-02-23 11:26 ` [Bug fortran/52351] " burnus at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-02-23 10:49 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52351
Bug #: 52351
Summary: Wrong bounds when passing an array section to an
intent-in pointer dummy
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: burnus@gcc.gnu.org
The following program should print:
3 6
1 4
but it wrongly prints
3 6
3 6
The program uses the Fortran 2008 feature that one can pass a nonpointer to an
intent(in) pointer argument.
>From the standard:
"12.5.2.7 Pointer dummy variables"
"If the dummy argument does not have the INTENT (IN), the actual argument shall
be a pointer. Otherwise, the actual argument shall be a pointer or a valid
target for the dummy pointer in a pointer assignment statement. If the actual
argument is not a pointer, the dummy pointer becomes pointer associated with
the actual argument."
"16.5.2 Pointer association"
"If the pointer has deferred type parameters or shape, their values are assumed
from the target."
As lbound(a(:)) == 1 (always) and lbound(a) == 3 (in this example), the
respective result should be obtained for lbound(x).
integer, allocatable, target :: A(:)
allocate(A(3:6))
call sub (a)
call sub (a(:))
contains
subroutine sub(x)
integer, pointer, intent(in) :: x(:)
print *, lbound(x), ubound(x)
end subroutine sub
end
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/52351] Wrong bounds when passing an array section to an intent-in pointer dummy
2012-02-23 10:49 [Bug fortran/52351] New: Wrong bounds when passing an array section to an intent-in pointer dummy burnus at gcc dot gnu.org
@ 2012-02-23 11:26 ` burnus at gcc dot gnu.org
2012-02-23 22:54 ` burnus at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-02-23 11:26 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52351
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu.org
--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-02-23 10:49:22 UTC ---
It works if one any other array section than "(:)" such as:
call sub (a(4:)) ! gives: 1 3
or even
call sub (a(3:)) ! gives: 1 4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/52351] Wrong bounds when passing an array section to an intent-in pointer dummy
2012-02-23 10:49 [Bug fortran/52351] New: Wrong bounds when passing an array section to an intent-in pointer dummy burnus at gcc dot gnu.org
2012-02-23 11:26 ` [Bug fortran/52351] " burnus at gcc dot gnu.org
@ 2012-02-23 22:54 ` burnus at gcc dot gnu.org
2013-06-20 18:10 ` dominiq at lps dot ens.fr
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-02-23 22:54 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52351
--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-02-23 22:34:31 UTC ---
The issue seems to be in gfc_conv_array_parameter - or rather in the called
gfc_conv_expr_descriptor. There, one has:
full = gfc_full_array_ref_p (info->ref, NULL);
if (full && !transposed_dims (ss))
else if (se->want_pointer)
se->expr = gfc_build_addr_expr (NULL_TREE, desc);
return;
However, that's wrong if one needs to modify the bounds. Thus, in this special
case (fsym == pointer/class_pointer && fsym->attr.intent == INTENT_IN plus last
ref != AR_FULL), one has to create a new descriptor.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/52351] Wrong bounds when passing an array section to an intent-in pointer dummy
2012-02-23 10:49 [Bug fortran/52351] New: Wrong bounds when passing an array section to an intent-in pointer dummy burnus at gcc dot gnu.org
2012-02-23 11:26 ` [Bug fortran/52351] " burnus at gcc dot gnu.org
2012-02-23 22:54 ` burnus at gcc dot gnu.org
@ 2013-06-20 18:10 ` dominiq at lps dot ens.fr
2020-06-11 12:21 ` cvs-commit at gcc dot gnu.org
2020-06-11 14:11 ` tkoenig at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: dominiq at lps dot ens.fr @ 2013-06-20 18:10 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52351
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-06-20
Ever confirmed|0 |1
--- Comment #3 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Still present at revision 200247.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/52351] Wrong bounds when passing an array section to an intent-in pointer dummy
2012-02-23 10:49 [Bug fortran/52351] New: Wrong bounds when passing an array section to an intent-in pointer dummy burnus at gcc dot gnu.org
` (2 preceding siblings ...)
2013-06-20 18:10 ` dominiq at lps dot ens.fr
@ 2020-06-11 12:21 ` cvs-commit at gcc dot gnu.org
2020-06-11 14:11 ` tkoenig at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-11 12:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52351
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Thomas Kथà¤nig <tkoenig@gcc.gnu.org>:
https://gcc.gnu.org/g:2ff0f48819c8a7ed5d7c03e2bfc02e5907e2ff1a
commit r11-1230-g2ff0f48819c8a7ed5d7c03e2bfc02e5907e2ff1a
Author: José Rui Faustino de Sousa <jrfsousa@gmail.com>
Date: Thu Jun 11 14:14:30 2020 +0200
Wrong array section bounds when passing to an intent-in pointer dummy.
Add code to allow for the creation a new descriptor for array
sections with the correct one based indexing.
Rework the generated descriptors indexing (hopefully) fixing the
wrong offsets generated.
gcc/fortran/ChangeLog:
2020-06-11 José Rui Faustino de Sousa <jrfsousa@gmail.com>
PR fortran/52351
PR fortran/85868
* trans-array.c (gfc_conv_expr_descriptor): Enable the
creation of a new descriptor with the correct one based
indexing for array sections. Rework array descriptor
indexing offset calculation.
gcc/testsuite/ChangeLog:
2020-06-11 José Rui Faustino de Sousa <jrfsousa@gmail.com>
PR fortran/52351
PR fortran/85868
* gfortran.dg/coarray_lib_comm_1.f90: Adjust match test for
the newly generated descriptor.
* gfortran.dg/PR85868A.f90: New test.
* gfortran.dg/PR85868B.f90: New test.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/52351] Wrong bounds when passing an array section to an intent-in pointer dummy
2012-02-23 10:49 [Bug fortran/52351] New: Wrong bounds when passing an array section to an intent-in pointer dummy burnus at gcc dot gnu.org
` (3 preceding siblings ...)
2020-06-11 12:21 ` cvs-commit at gcc dot gnu.org
@ 2020-06-11 14:11 ` tkoenig at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2020-06-11 14:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52351
Thomas Koenig <tkoenig at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #6 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Fixed on master.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-06-11 14:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-23 10:49 [Bug fortran/52351] New: Wrong bounds when passing an array section to an intent-in pointer dummy burnus at gcc dot gnu.org
2012-02-23 11:26 ` [Bug fortran/52351] " burnus at gcc dot gnu.org
2012-02-23 22:54 ` burnus at gcc dot gnu.org
2013-06-20 18:10 ` dominiq at lps dot ens.fr
2020-06-11 12:21 ` cvs-commit at gcc dot gnu.org
2020-06-11 14:11 ` tkoenig 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).