* [Bug fortran/67740] Wrong association status of allocatable character pointer in derived types
2015-09-28 6:59 [Bug fortran/67740] New: Wrong association status of allocatable character pointer in derived types baradi09 at gmail dot com
@ 2015-10-10 10:05 ` dominiq at lps dot ens.fr
2021-05-03 12:51 ` bardeau at iram dot fr
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-10-10 10:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67740
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-10-10
Ever confirmed|0 |1
--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Confirmed with 5.2 and 6.0. I get the following ICE with 4.9
pr67740.f90:20:0: internal compiler error: in gimplify_expr, at gimplify.c:8538
allocate(character(4) :: myBase%string)
the change occurred between revisions r221423 (2015-03-13, ICE) and
r2214164+patches (2015-03-16, compiles).
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/67740] Wrong association status of allocatable character pointer in derived types
2015-09-28 6:59 [Bug fortran/67740] New: Wrong association status of allocatable character pointer in derived types baradi09 at gmail dot com
2015-10-10 10:05 ` [Bug fortran/67740] " dominiq at lps dot ens.fr
@ 2021-05-03 12:51 ` bardeau at iram dot fr
2023-09-26 19:57 ` anlauf at gcc dot gnu.org
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: bardeau at iram dot fr @ 2021-05-03 12:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67740
Sebastien Bardeau <bardeau at iram dot fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bardeau at iram dot fr
--- Comment #4 from Sebastien Bardeau <bardeau at iram dot fr> ---
I have pretty much the same kind of issue with gfortran 10.2.0 and 11.0.1
(20210426). The following code shows invalid results (printed lengths are 0).
Sometimes I even get a program crash. If the 'data1' component is a standalone
pointer (i.e. out of the derived type), I have no issue then.
program test2
character(len=10), target, allocatable :: s(:)
type :: pointer_typec0_t
character(len=:), pointer :: data1(:)
end type pointer_typec0_t
type(pointer_typec0_t) :: co
!
allocate(s(3))
s(1) = '1234567890'
s(2) = 'qwertyuio '
s(3) = 'asdfghjk '
!
co%data1 => s
!
print *,len(co%data1(1)),len_trim(co%data1(1)),co%data1(1)
print *,len(co%data1(2)),len_trim(co%data1(2)),co%data1(2)
print *,len(co%data1(3)),len_trim(co%data1(3)),co%data1(3)
end program test2
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/67740] Wrong association status of allocatable character pointer in derived types
2015-09-28 6:59 [Bug fortran/67740] New: Wrong association status of allocatable character pointer in derived types baradi09 at gmail dot com
2015-10-10 10:05 ` [Bug fortran/67740] " dominiq at lps dot ens.fr
2021-05-03 12:51 ` bardeau at iram dot fr
@ 2023-09-26 19:57 ` anlauf at gcc dot gnu.org
2023-09-26 20:28 ` anlauf at gcc dot gnu.org
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-09-26 19:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67740
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |anlauf at gcc dot gnu.org
--- Comment #5 from anlauf at gcc dot gnu.org ---
Created attachment 55998
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55998&action=edit
Testcase for scalar pointer
The original testcase from comment#0 failed with 9.5.0, but works with 10.5.0
and newer. An extended deja-gnuified testcase for this is attached.
The variant with array-valued pointers in comment#4 still fails.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/67740] Wrong association status of allocatable character pointer in derived types
2015-09-28 6:59 [Bug fortran/67740] New: Wrong association status of allocatable character pointer in derived types baradi09 at gmail dot com
` (2 preceding siblings ...)
2023-09-26 19:57 ` anlauf at gcc dot gnu.org
@ 2023-09-26 20:28 ` anlauf at gcc dot gnu.org
2023-09-27 20:07 ` anlauf at gcc dot gnu.org
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-09-26 20:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67740
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
--- Comment #6 from anlauf at gcc dot gnu.org ---
Extending the testcase in comment#4:
program test2
implicit none
character(len=10), allocatable, target :: s(:)
character(len=:), pointer :: sptr(:)
type :: pointer_typec0_t
character(len=:), pointer :: data1(:)
end type pointer_typec0_t
type(pointer_typec0_t) :: co
!
allocate(s(3))
s(1) = '1234567890'
s(2) = 'qwertyuio '
s(3) = 'asdfghjk '
!
sptr => s
print *, sptr ! OK
co%data1 => s
print *, co%data1 ! not OK
!
print *,len(co%data1(1)),len_trim(co%data1(1)),co%data1(1)
print *,len(co%data1(2)),len_trim(co%data1(2)),co%data1(2)
print *,len(co%data1(3)),len_trim(co%data1(3)),co%data1(3)
end program test2
The tree-dump has:
.sptr = 10;
sptr = s;
sptr.span = s.span;
but
co.data1 = s;
co.data1.span = s.span;
so we don't set the character length in the association.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/67740] Wrong association status of allocatable character pointer in derived types
2015-09-28 6:59 [Bug fortran/67740] New: Wrong association status of allocatable character pointer in derived types baradi09 at gmail dot com
` (3 preceding siblings ...)
2023-09-26 20:28 ` anlauf at gcc dot gnu.org
@ 2023-09-27 20:07 ` anlauf at gcc dot gnu.org
2023-10-08 8:44 ` pault at gcc dot gnu.org
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-09-27 20:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67740
--- Comment #7 from anlauf at gcc dot gnu.org ---
The following snippet in gfc_trans_pointer_assignment looks suspicious:
if (expr1->ts.type == BT_CHARACTER
&& expr1->symtree->n.sym->ts.deferred
&& expr1->symtree->n.sym->ts.u.cl->backend_decl
&& VAR_P (expr1->symtree->n.sym->ts.u.cl->backend_decl))
{
tmp = expr1->symtree->n.sym->ts.u.cl->backend_decl;
if (expr2->expr_type != EXPR_NULL)
gfc_add_modify (&block, tmp,
fold_convert (TREE_TYPE (tmp), strlen_rhs));
else
gfc_add_modify (&block, tmp, build_zero_cst (TREE_TYPE (tmp)));
}
I wonder whether it should read:
if (expr1->ts.type == BT_CHARACTER
&& expr1->ts.deferred
...
Furthermore, expr1->ts.u.cl->backend_decl appears not set properly,
and I fail to see why.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/67740] Wrong association status of allocatable character pointer in derived types
2015-09-28 6:59 [Bug fortran/67740] New: Wrong association status of allocatable character pointer in derived types baradi09 at gmail dot com
` (4 preceding siblings ...)
2023-09-27 20:07 ` anlauf at gcc dot gnu.org
@ 2023-10-08 8:44 ` pault at gcc dot gnu.org
2023-10-08 20:43 ` anlauf at gcc dot gnu.org
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: pault at gcc dot gnu.org @ 2023-10-08 8:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67740
Paul Thomas <pault at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pault at gcc dot gnu.org
--- Comment #8 from Paul Thomas <pault at gcc dot gnu.org> ---
Created attachment 56073
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56073&action=edit
"Fix" for this PR
Hi Harald,
You are touching the right place. However, this should be happening in
gfc_conv_expr_descriptor I would have thought so that strlen_lhs comes back
with the correct value.
Cheers
Paul
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/67740] Wrong association status of allocatable character pointer in derived types
2015-09-28 6:59 [Bug fortran/67740] New: Wrong association status of allocatable character pointer in derived types baradi09 at gmail dot com
` (5 preceding siblings ...)
2023-10-08 8:44 ` pault at gcc dot gnu.org
@ 2023-10-08 20:43 ` anlauf at gcc dot gnu.org
2023-10-09 20:29 ` anlauf at gcc dot gnu.org
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-10-08 20:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67740
--- Comment #9 from anlauf at gcc dot gnu.org ---
(In reply to Paul Thomas from comment #8)
> Created attachment 56073 [details]
> "Fix" for this PR
>
> Hi Harald,
>
> You are touching the right place. However, this should be happening in
> gfc_conv_expr_descriptor I would have thought so that strlen_lhs comes back
> with the correct value.
Yes, this might be a latent issue still showing up elsewhere for deferred
length, although your patch seems to fix cases immediately related to
those in this PR.
I was suspecting gfc_conv_variable as a possibly further place for a fix:
it has a loop over ref's that looks incomplete for REF_COMPONENT.
Nevertheless, your patch works for me.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/67740] Wrong association status of allocatable character pointer in derived types
2015-09-28 6:59 [Bug fortran/67740] New: Wrong association status of allocatable character pointer in derived types baradi09 at gmail dot com
` (6 preceding siblings ...)
2023-10-08 20:43 ` anlauf at gcc dot gnu.org
@ 2023-10-09 20:29 ` anlauf at gcc dot gnu.org
2023-10-12 6:27 ` cvs-commit at gcc dot gnu.org
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-10-09 20:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67740
--- Comment #10 from anlauf at gcc dot gnu.org ---
(In reply to anlauf from comment #9)
Addendum:
> I was suspecting gfc_conv_variable as a possibly further place for a fix:
> it has a loop over ref's that looks incomplete for REF_COMPONENT.
I tried my version of a patch in that place, which worked for the testcases
here but gave wrong code already for slightly more complex pointer assignments,
like
type(pointer_typec0_t) :: co, xo
...
xo%data1 => co%data1
so let's go with your patch.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/67740] Wrong association status of allocatable character pointer in derived types
2015-09-28 6:59 [Bug fortran/67740] New: Wrong association status of allocatable character pointer in derived types baradi09 at gmail dot com
` (7 preceding siblings ...)
2023-10-09 20:29 ` anlauf at gcc dot gnu.org
@ 2023-10-12 6:27 ` cvs-commit at gcc dot gnu.org
2023-10-26 9:36 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-10-12 6:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67740
--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Paul Thomas <pault@gcc.gnu.org>:
https://gcc.gnu.org/g:701363d827d45d3e3601735fa42f95644fda8b64
commit r14-4583-g701363d827d45d3e3601735fa42f95644fda8b64
Author: Paul Thomas <pault@gcc.gnu.org>
Date: Thu Oct 12 07:26:59 2023 +0100
Fortran: Set hidden string length for pointer components [PR67740].
2023-10-11 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/67740
* trans-expr.cc (gfc_trans_pointer_assignment): Set the hidden
string length component for pointer assignment to character
pointer components.
gcc/testsuite/
PR fortran/67740
* gfortran.dg/pr67740.f90: New test
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/67740] Wrong association status of allocatable character pointer in derived types
2015-09-28 6:59 [Bug fortran/67740] New: Wrong association status of allocatable character pointer in derived types baradi09 at gmail dot com
` (8 preceding siblings ...)
2023-10-12 6:27 ` cvs-commit at gcc dot gnu.org
@ 2023-10-26 9:36 ` cvs-commit at gcc dot gnu.org
2023-10-26 9:39 ` pault at gcc dot gnu.org
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-10-26 9:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67740
--- Comment #12 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Paul Thomas <pault@gcc.gnu.org>:
https://gcc.gnu.org/g:6fb12d3a0456a3503a670d95803aef10549f0134
commit r13-7986-g6fb12d3a0456a3503a670d95803aef10549f0134
Author: Paul Thomas <pault@gcc.gnu.org>
Date: Thu Oct 12 07:26:59 2023 +0100
Fortran: Set hidden string length for pointer components [PR67740].
2023-10-11 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/67740
* trans-expr.cc (gfc_trans_pointer_assignment): Set the hidden
string length component for pointer assignment to character
pointer components.
gcc/testsuite/
PR fortran/67740
* gfortran.dg/pr67740.f90: New test
(cherry picked from commit 701363d827d45d3e3601735fa42f95644fda8b64)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/67740] Wrong association status of allocatable character pointer in derived types
2015-09-28 6:59 [Bug fortran/67740] New: Wrong association status of allocatable character pointer in derived types baradi09 at gmail dot com
` (9 preceding siblings ...)
2023-10-26 9:36 ` cvs-commit at gcc dot gnu.org
@ 2023-10-26 9:39 ` pault at gcc dot gnu.org
2023-10-26 12:08 ` baradi09 at gmail dot com
2024-05-14 20:06 ` anlauf at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: pault at gcc dot gnu.org @ 2023-10-26 9:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67740
Paul Thomas <pault at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #13 from Paul Thomas <pault at gcc dot gnu.org> ---
Fixed on 13-branch and trunk.
Thanks for the report
Paul
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/67740] Wrong association status of allocatable character pointer in derived types
2015-09-28 6:59 [Bug fortran/67740] New: Wrong association status of allocatable character pointer in derived types baradi09 at gmail dot com
` (10 preceding siblings ...)
2023-10-26 9:39 ` pault at gcc dot gnu.org
@ 2023-10-26 12:08 ` baradi09 at gmail dot com
2024-05-14 20:06 ` anlauf at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: baradi09 at gmail dot com @ 2023-10-26 12:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67740
--- Comment #14 from Bálint Aradi <baradi09 at gmail dot com> ---
Thanks a lot for fixing it!
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/67740] Wrong association status of allocatable character pointer in derived types
2015-09-28 6:59 [Bug fortran/67740] New: Wrong association status of allocatable character pointer in derived types baradi09 at gmail dot com
` (11 preceding siblings ...)
2023-10-26 12:08 ` baradi09 at gmail dot com
@ 2024-05-14 20:06 ` anlauf at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-05-14 20:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67740
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |clange001 at gmail dot com
--- Comment #15 from anlauf at gcc dot gnu.org ---
*** Bug 106317 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 14+ messages in thread