Discussion:
[Patc, fortran] PR85603 - ICE with character array substring assignment
Paul Richard Thomas
2018-09-22 10:23:46 UTC
Permalink
Yet another 'obvious' deferred character fix. Committed to trunk as
r264502. Will backport in about ten days time.

Paul

2018-09-22 Paul Thomas <***@gcc.gnu.org>

PR fortran/85603
* trans-array.c (gfc_alloc_allocatable_for_assignment): Test
the charlen backend_decl before using the VAR_P macro.

2018-09-22 Paul Thomas <***@gcc.gnu.org>

PR fortran/85603
* gfortran.dg/deferred_character_23.f90 : New test.
Paul Richard Thomas
2018-10-18 16:25:17 UTC
Permalink
It turned out that this patch did not quite complete the job (Thanks
Walt): The ICE has gone but reallocation on assignment is not
occurring because the correct string length for the rhs expression was
not being picked up. The fix for this took rather more detective work
than I anticipated but here it is.

Bootstraps and regtests on FC28/x86_64 - OK for trunk?

Cheers

Paul

2018-10-18 Paul Thomas <***@gcc.gnu.org>

PR fortran/85603
* frontend-passes.c (get_len_call): New function to generate a
call to intrinsic LEN.
(create_var): Use this to make length expressions for variable
rhs string lengths.
Clean up some white space issues.

2018-10-18 Paul Thomas <***@gcc.gnu.org>

PR fortran/85603
* gfortran.dg/deferred_character_23.f90 : Check reallocation is
occurring as it should..

On Sat, 22 Sep 2018 at 11:23, Paul Richard Thomas
Post by Paul Richard Thomas
Yet another 'obvious' deferred character fix. Committed to trunk as
r264502. Will backport in about ten days time.
Paul
PR fortran/85603
* trans-array.c (gfc_alloc_allocatable_for_assignment): Test
the charlen backend_decl before using the VAR_P macro.
PR fortran/85603
* gfortran.dg/deferred_character_23.f90 : New test.
--
"If you can't explain it simply, you don't understand it well enough"
- Albert Einstein
Dominique d'Humières
2018-10-19 21:39:22 UTC
Permalink
Hi Paul,

I get a regression with your patch:

obfuscated_tn4.f90:300:0:

300 | TP6%ROR=TP6%ROR(:PP4-1)
|
internal compiler error: in gfc_trans_deferred_vars, at fortran/trans-decl.c:4754


I’ll try to reduce the test.

Dominique
Dominique d'Humières
2018-10-19 22:15:35 UTC
Permalink
Reduced test

! { dg-do compile }
MODULE TN4
IMPLICIT NONE
PRIVATE
INTEGER,PARAMETER::SH4=KIND('a')
TYPE,PUBLIC::TOP
CHARACTER(:,KIND=SH4),ALLOCATABLE::ROR
CHARACTER(:,KIND=SH4),ALLOCATABLE::VI8
CONTAINS
PROCEDURE,NON_OVERRIDABLE::SB=>TPX
END TYPE TOP
CONTAINS
SUBROUTINE TPX(TP6,PP4,BA3)
CLASS(TOP),INTENT(INOUT)::TP6
INTEGER,INTENT(IN)::PP4
TYPE(TOP),INTENT(OUT)::BA3
BA3%ROR=TP6%ROR(PP4:)
BA3%VI8=TP6%ROR(PP4:)
TP6%ROR=TP6%ROR(:PP4-1)
TP6%VI8=TP6%ROR(:PP4-1)
END SUBROUTINE TPX
END MODULE TN4
! https://groups.google.com/forum/#!topic/comp.lang.fortran/nV3TlRlVKBc

TIA

Dominique
Post by Dominique d'Humières
Hi Paul,
300 | TP6%ROR=TP6%ROR(:PP4-1)
|
internal compiler error: in gfc_trans_deferred_vars, at fortran/trans-decl.c:4754
I’ll try to reduce the test.
Dominique
Paul Richard Thomas
2018-10-20 12:32:38 UTC
Permalink
Hi Dominique,

Thanks for picking that up. For some reason that I do now see, the
regression is caused by the component references. The frontend
temporary is picking up the deferred tag from somewhere, even though
it is not set. Anyway, all is well if the patch is restricted to
character right hand side symbols. I have added a test for the
regression to the testcase.

OK for trunk?

Paul
Post by Dominique d'Humières
Reduced test
! { dg-do compile }
MODULE TN4
IMPLICIT NONE
PRIVATE
INTEGER,PARAMETER::SH4=KIND('a')
TYPE,PUBLIC::TOP
CHARACTER(:,KIND=SH4),ALLOCATABLE::ROR
CHARACTER(:,KIND=SH4),ALLOCATABLE::VI8
CONTAINS
PROCEDURE,NON_OVERRIDABLE::SB=>TPX
END TYPE TOP
CONTAINS
SUBROUTINE TPX(TP6,PP4,BA3)
CLASS(TOP),INTENT(INOUT)::TP6
INTEGER,INTENT(IN)::PP4
TYPE(TOP),INTENT(OUT)::BA3
BA3%ROR=TP6%ROR(PP4:)
BA3%VI8=TP6%ROR(PP4:)
TP6%ROR=TP6%ROR(:PP4-1)
TP6%VI8=TP6%ROR(:PP4-1)
END SUBROUTINE TPX
END MODULE TN4
! https://groups.google.com/forum/#!topic/comp.lang.fortran/nV3TlRlVKBc
TIA
Dominique
Post by Dominique d'Humières
Hi Paul,
300 | TP6%ROR=TP6%ROR(:PP4-1)
|
internal compiler error: in gfc_trans_deferred_vars, at fortran/trans-decl.c:4754
I’ll try to reduce the test.
Dominique
--
"If you can't explain it simply, you don't understand it well enough"
- Albert Einstein
Paul Richard Thomas
2018-10-20 12:38:32 UTC
Permalink
Hmmm! It helps to provide the patch.

2018-10-18 Paul Thomas <***@gcc.gnu.org>

PR fortran/85603
* frontend-passes.c (get_len_call): New function to generate a
call to intrinsic LEN.
(create_var): Use this to make length expressions for variable
rhs string lengths.
Clean up some white space issues.

2018-10-18 Paul Thomas <***@gcc.gnu.org>

PR fortran/85603
* gfortran.dg/deferred_character_23.f90 : Check reallocation is
occurring as it should and a regression caused by version 1 of
this patch.

On Sat, 20 Oct 2018 at 13:32, Paul Richard Thomas
Post by Paul Richard Thomas
Hi Dominique,
Thanks for picking that up. For some reason that I do now see, the
regression is caused by the component references. The frontend
temporary is picking up the deferred tag from somewhere, even though
it is not set. Anyway, all is well if the patch is restricted to
character right hand side symbols. I have added a test for the
regression to the testcase.
OK for trunk?
Paul
Post by Dominique d'Humières
Reduced test
! { dg-do compile }
MODULE TN4
IMPLICIT NONE
PRIVATE
INTEGER,PARAMETER::SH4=KIND('a')
TYPE,PUBLIC::TOP
CHARACTER(:,KIND=SH4),ALLOCATABLE::ROR
CHARACTER(:,KIND=SH4),ALLOCATABLE::VI8
CONTAINS
PROCEDURE,NON_OVERRIDABLE::SB=>TPX
END TYPE TOP
CONTAINS
SUBROUTINE TPX(TP6,PP4,BA3)
CLASS(TOP),INTENT(INOUT)::TP6
INTEGER,INTENT(IN)::PP4
TYPE(TOP),INTENT(OUT)::BA3
BA3%ROR=TP6%ROR(PP4:)
BA3%VI8=TP6%ROR(PP4:)
TP6%ROR=TP6%ROR(:PP4-1)
TP6%VI8=TP6%ROR(:PP4-1)
END SUBROUTINE TPX
END MODULE TN4
! https://groups.google.com/forum/#!topic/comp.lang.fortran/nV3TlRlVKBc
TIA
Dominique
Post by Dominique d'Humières
Hi Paul,
300 | TP6%ROR=TP6%ROR(:PP4-1)
|
internal compiler error: in gfc_trans_deferred_vars, at fortran/trans-decl.c:4754
I’ll try to reduce the test.
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
Thomas Koenig
2018-10-21 10:28:52 UTC
Permalink
Hi Paul,
Post by Paul Richard Thomas
PR fortran/85603
* frontend-passes.c (get_len_call): New function to generate a
call to intrinsic LEN.
(create_var): Use this to make length expressions for variable
rhs string lengths.
Clean up some white space issues.
PR fortran/85603
* gfortran.dg/deferred_character_23.f90 : Check reallocation is
occurring as it should and a regression caused by version 1 of
this patch.
OK.

Thanks for the patch!

Regards

Thomas

Loading...