* Re: [Patch, fortran] PR65677 - Incomplete assignment on deferred-length character variable
@ 2018-09-30 17:16 Dominique d'Humières
2018-10-01 7:55 ` Paul Richard Thomas
0 siblings, 1 reply; 5+ messages in thread
From: Dominique d'Humières @ 2018-09-30 17:16 UTC (permalink / raw)
To: Paul Richard Thomas; +Cc: gfortran, gcc-patches
Hi Paul,
First your patch has been committed with wrong entry: 65667 instead of 65677.
Second, I suspect it is responsible of the following ICE:
% gfc pr72755.f90 -fno-range-check
pr72755.f90:1485:0:
1485 | this%buffer = transfer( c(start:iend), this%buffer )
|
internal compiler error: in gfc_dep_resolver, at fortran/dependency.c:2257
and
% gfc pr64125_db.f90
pr64125_db.f90:20:0:
20 | left%chars = transfer( right, left%chars )
|
internal compiler error: in gfc_dep_resolver, at fortran/dependency.c:2257
for
module test
type t_string
private
character(len=:), allocatable :: chars
end type t_string
contains
pure subroutine string_assign_from_array( left, right )
! The target string
type(t_string), intent(out) :: left
! The source string
character, dimension(:), intent(in) :: right
! Copy memory
allocate( character(len=size(right)) :: left%chars )
left%chars = transfer( right, left%chars )
end subroutine string_assign_from_array
end module test
Cheers,
Dominique
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Patch, fortran] PR65677 - Incomplete assignment on deferred-length character variable
2018-09-30 17:16 [Patch, fortran] PR65677 - Incomplete assignment on deferred-length character variable Dominique d'Humières
@ 2018-10-01 7:55 ` Paul Richard Thomas
2018-10-01 10:19 ` Paul Richard Thomas
0 siblings, 1 reply; 5+ messages in thread
From: Paul Richard Thomas @ 2018-10-01 7:55 UTC (permalink / raw)
To: Dominique Dhumieres; +Cc: fortran
[-- Attachment #1: Type: text/plain, Size: 1731 bytes --]
Hi Dominique,
I seem to have got the wrong PR number right from the moment that I
created the directory for it and kept copying it thereafter -
apologies, I will put it right.
As to the regression, the fix is simple and is attached. I had quite
forgotten about that assertion, which I am not very convinced is
necessary.
Many thanks for alerting me to these problems.
Paul
On Sun, 30 Sep 2018 at 18:16, Dominique d'Humières <dominiq@lps.ens.fr> wrote:
>
> Hi Paul,
>
> First your patch has been committed with wrong entry: 65667 instead of 65677.
>
> Second, I suspect it is responsible of the following ICE:
>
> % gfc pr72755.f90 -fno-range-check
> pr72755.f90:1485:0:
>
> 1485 | this%buffer = transfer( c(start:iend), this%buffer )
> |
> internal compiler error: in gfc_dep_resolver, at fortran/dependency.c:2257
>
> and
>
> % gfc pr64125_db.f90
> pr64125_db.f90:20:0:
>
> 20 | left%chars = transfer( right, left%chars )
> |
> internal compiler error: in gfc_dep_resolver, at fortran/dependency.c:2257
>
> for
>
> module test
> type t_string
> private
> character(len=:), allocatable :: chars
> end type t_string
>
> contains
>
> pure subroutine string_assign_from_array( left, right )
>
> ! The target string
> type(t_string), intent(out) :: left
>
> ! The source string
> character, dimension(:), intent(in) :: right
>
>
> ! Copy memory
> allocate( character(len=size(right)) :: left%chars )
> left%chars = transfer( right, left%chars )
>
> end subroutine string_assign_from_array
>
> end module test
>
> Cheers,
>
> Dominique
>
--
"If you can't explain it simply, you don't understand it well enough"
- Albert Einstein
[-- Attachment #2: regression.diff --]
[-- Type: text/x-patch, Size: 1002 bytes --]
Index: gcc/fortran/trans-expr.c
===================================================================
*** gcc/fortran/trans-expr.c (revision 264724)
--- gcc/fortran/trans-expr.c (working copy)
*************** gfc_trans_assignment_1 (gfc_expr * expr1
*** 10208,10214 ****
string_length = gfc_evaluate_now (rse.string_length, &rse.pre);
else if (expr2->ts.type == BT_CHARACTER)
{
! if (expr1->ts.deferred && gfc_check_dependency (expr1, expr2, false))
rse.string_length = gfc_evaluate_now (rse.string_length, &rse.pre);
string_length = rse.string_length;
}
--- 10208,10216 ----
string_length = gfc_evaluate_now (rse.string_length, &rse.pre);
else if (expr2->ts.type == BT_CHARACTER)
{
! if (expr1->ts.deferred
! && rss != gfc_ss_terminator && lss != gfc_ss_terminator
! && gfc_check_dependency (expr1, expr2, false))
rse.string_length = gfc_evaluate_now (rse.string_length, &rse.pre);
string_length = rse.string_length;
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Patch, fortran] PR65677 - Incomplete assignment on deferred-length character variable
2018-10-01 7:55 ` Paul Richard Thomas
@ 2018-10-01 10:19 ` Paul Richard Thomas
0 siblings, 0 replies; 5+ messages in thread
From: Paul Richard Thomas @ 2018-10-01 10:19 UTC (permalink / raw)
To: Dominique Dhumieres; +Cc: fortran
The attached fix breaks the very thing that I set out to fix in the
first place. I'm working on it.
Paul
On Mon, 1 Oct 2018 at 08:54, Paul Richard Thomas
<paul.richard.thomas@gmail.com> wrote:
>
> Hi Dominique,
>
> I seem to have got the wrong PR number right from the moment that I
> created the directory for it and kept copying it thereafter -
> apologies, I will put it right.
>
> As to the regression, the fix is simple and is attached. I had quite
> forgotten about that assertion, which I am not very convinced is
> necessary.
>
> Many thanks for alerting me to these problems.
>
> Paul
>
> On Sun, 30 Sep 2018 at 18:16, Dominique d'Humières <dominiq@lps.ens.fr> wrote:
> >
> > Hi Paul,
> >
> > First your patch has been committed with wrong entry: 65667 instead of 65677.
> >
> > Second, I suspect it is responsible of the following ICE:
> >
> > % gfc pr72755.f90 -fno-range-check
> > pr72755.f90:1485:0:
> >
> > 1485 | this%buffer = transfer( c(start:iend), this%buffer )
> > |
> > internal compiler error: in gfc_dep_resolver, at fortran/dependency.c:2257
> >
> > and
> >
> > % gfc pr64125_db.f90
> > pr64125_db.f90:20:0:
> >
> > 20 | left%chars = transfer( right, left%chars )
> > |
> > internal compiler error: in gfc_dep_resolver, at fortran/dependency.c:2257
> >
> > for
> >
> > module test
> > type t_string
> > private
> > character(len=:), allocatable :: chars
> > end type t_string
> >
> > contains
> >
> > pure subroutine string_assign_from_array( left, right )
> >
> > ! The target string
> > type(t_string), intent(out) :: left
> >
> > ! The source string
> > character, dimension(:), intent(in) :: right
> >
> >
> > ! Copy memory
> > allocate( character(len=size(right)) :: left%chars )
> > left%chars = transfer( right, left%chars )
> >
> > end subroutine string_assign_from_array
> >
> > end module test
> >
> > Cheers,
> >
> > Dominique
> >
>
>
> --
> "If you can't explain it simply, you don't understand it well enough"
> - Albert Einstein
--
"If you can't explain it simply, you don't understand it well enough"
- Albert Einstein
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Patch, fortran] PR65677 - Incomplete assignment on deferred-length character variable
2018-09-23 11:57 Paul Richard Thomas
@ 2018-09-23 16:09 ` Janne Blomqvist
0 siblings, 0 replies; 5+ messages in thread
From: Janne Blomqvist @ 2018-09-23 16:09 UTC (permalink / raw)
To: Paul Richard Thomas; +Cc: Fortran List, GCC Patches
On Sun, Sep 23, 2018 at 2:57 PM Paul Richard Thomas <
paul.richard.thomas@gmail.com> wrote:
> This is yet another deferred character length problem that this time
> is caused by a dependency in assignment between lhs and rhs
> string_lengths. The comment in the testcase explains all.
>
> Bootstraps and regtests on FC21/x86_64 - OK for trunk and 8-branch?
>
Ok, thanks.
--
Janne Blomqvist
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Patch, fortran] PR65677 - Incomplete assignment on deferred-length character variable
@ 2018-09-23 11:57 Paul Richard Thomas
2018-09-23 16:09 ` Janne Blomqvist
0 siblings, 1 reply; 5+ messages in thread
From: Paul Richard Thomas @ 2018-09-23 11:57 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 578 bytes --]
This is yet another deferred character length problem that this time
is caused by a dependency in assignment between lhs and rhs
string_lengths. The comment in the testcase explains all.
Bootstraps and regtests on FC21/x86_64 - OK for trunk and 8-branch?
I cannot commit until next week.
Paul
2018-09-23 Paul Thomas <pault@gcc.gnu.org>
PR fortran/65667
* trans-expr.c (gfc_trans_assignment_1): If there is dependency
fix the rse stringlength.
2018-09-23 Paul Thomas <pault@gcc.gnu.org>
PR fortran/65667
* gfortran.dg/dependency_52.f90 : New test.
[-- Attachment #2: submit.diff --]
[-- Type: text/x-patch, Size: 712 bytes --]
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 1453828..6a05412 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -10187,7 +10187,11 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag,
|| TREE_CODE (rse.string_length) == INDIRECT_REF))
string_length = gfc_evaluate_now (rse.string_length, &rse.pre);
else if (expr2->ts.type == BT_CHARACTER)
- string_length = rse.string_length;
+ {
+ if (expr1->ts.deferred && gfc_check_dependency (expr1, expr2, false))
+ rse.string_length = gfc_evaluate_now (rse.string_length, &rse.pre);
+ string_length = rse.string_length;
+ }
else
string_length = NULL_TREE;
[-- Attachment #3: dependency_52.f90 --]
[-- Type: text/x-fortran, Size: 1188 bytes --]
! { dg-do run }
!
! Test the fix for PR65667, in which the dependency was missed and
! the string length of 'text' was decremented twice. The rhs string
! length is now fixed after the function call so that the dependency
! on the length of 'text' is removed for later evaluations.
!
!Contributed by John <jwmwalrus@gmail.com>
!
module mod1
implicit none
contains
subroutine getKeyword(string, keyword, rest)
character(:), allocatable, intent(IN) :: string
character(:), allocatable, intent(OUT) :: keyword, rest
integer :: idx
character(:), allocatable :: text
keyword = ''
rest = ''
text = string
text = ADJUSTL(text(2:)) ! Note dependency.
idx = INDEX(text, ' ')
if (idx == 0) then
keyword = TRIM(text)
else
keyword = text(:idx-1)
rest = TRIM(ADJUSTL(text(idx+1:)))
endif
end subroutine
end module mod1
use mod1
implicit none
character(:), allocatable :: line, keyword, rest
line = '@HERE IT IS'
call getKeyword(line, keyword, rest)
if (keyword .ne. 'HERE') stop 1
if (rest .ne. 'IT IS') stop 2
end
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-10-01 10:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-30 17:16 [Patch, fortran] PR65677 - Incomplete assignment on deferred-length character variable Dominique d'Humières
2018-10-01 7:55 ` Paul Richard Thomas
2018-10-01 10:19 ` Paul Richard Thomas
-- strict thread matches above, loose matches on Subject: below --
2018-09-23 11:57 Paul Richard Thomas
2018-09-23 16:09 ` Janne Blomqvist
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).