Discussion:
[Patch, fortran] PR58618 - Wrong code with character substring and ASSOCIATE
Paul Richard Thomas
2018-10-17 10:32:46 UTC
Permalink
This problem concerned associate targets being substrings. It turns
out that they are returned as pointer types (with a different cast for
unity based substrings ***sigh***) and so can be assigned directly to
the associate name. The patch quite simply removed the condition that
such targets be allocatable, pointer or dummy.

I noticed in the course of working up the testcase that
character (:), pointer :: ptr => NULL()
character (6), target :: tgt = 'lmnopq'
ptr => tgt
print *, len (ptr), ptr
end
ICEs on the NULL initialization of the pointer but works fine if this
is removed. Has this already been posted as a PR?

Bootstrapped and regtested on FC28/x86_64 - OK for trunk?

Paul

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

PR fortran/58618
* trans-stmt.c (trans_associate_var): All strings that return
as pointer types can be assigned directly to the associate
name so remove 'attr' and the condition that uses it.

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

PR fortran/58618
* gfortran.dg/associate_45.f90 : New test.
Tobias Burnus
2018-10-17 21:17:29 UTC
Permalink
Hi Paul,
Post by Paul Richard Thomas
This problem concerned associate targets being substrings. It turns
out that they are returned as pointer types (with a different cast for
unity based substrings ***sigh***) and so can be assigned directly to
the associate name. The patch quite simply removed the condition that
such targets be allocatable, pointer or dummy.
I noticed in the course of working up the testcase that
character (:), pointer :: ptr => NULL()
character (6), target :: tgt = 'lmnopq'
ptr => tgt
print *, len (ptr), ptr
end
ICEs on the NULL initialization of the pointer but works fine if this
is removed. Has this already been posted as a PR?
I leave it to Dominique to search for a PR; otherwise, I believe the
attach patch fixes the issue. – It just needs someone to package it with
a test case, regtest and commit it.
Post by Paul Richard Thomas
Bootstrapped and regtested on FC28/x86_64 - OK for trunk?
OK – thanks for the fix.

Tobias
Post by Paul Richard Thomas
PR fortran/58618
* trans-stmt.c (trans_associate_var): All strings that return
as pointer types can be assigned directly to the associate
name so remove 'attr' and the condition that uses it.
PR fortran/58618
* gfortran.dg/associate_45.f90 : New test.
Paul Richard Thomas
2018-10-18 10:10:36 UTC
Permalink
I do not think that there will be a PR for the ICE. This is a
regression introduced by my patch for PR70149 (September 30th). A
patch is attached. I will commit it as 'obvious' as soon as it has
finished regtesting. I will also commit the patch for PR58618 shortly
afterwards. Thanks for the review.

Paul
Post by Tobias Burnus
Hi Paul,
Post by Paul Richard Thomas
This problem concerned associate targets being substrings. It turns
out that they are returned as pointer types (with a different cast for
unity based substrings ***sigh***) and so can be assigned directly to
the associate name. The patch quite simply removed the condition that
such targets be allocatable, pointer or dummy.
I noticed in the course of working up the testcase that
character (:), pointer :: ptr => NULL()
character (6), target :: tgt = 'lmnopq'
ptr => tgt
print *, len (ptr), ptr
end
ICEs on the NULL initialization of the pointer but works fine if this
is removed. Has this already been posted as a PR?
I leave it to Dominique to search for a PR; otherwise, I believe the
attach patch fixes the issue. – It just needs someone to package it with
a test case, regtest and commit it.
Post by Paul Richard Thomas
Bootstrapped and regtested on FC28/x86_64 - OK for trunk?
OK – thanks for the fix.
Tobias
Post by Paul Richard Thomas
PR fortran/58618
* trans-stmt.c (trans_associate_var): All strings that return
as pointer types can be assigned directly to the associate
name so remove 'attr' and the condition that uses it.
PR fortran/58618
* gfortran.dg/associate_45.f90 : New test.
--
"If you can't explain it simply, you don't understand it well enough"
- Albert Einstein
Paul Richard Thomas
2018-10-18 10:38:43 UTC
Permalink
Patch for the PR70149 regression committed as revision 265263.

Likewise the patch for PR58618 has been committed as revision 265264.

Cheers

Paul
Post by Tobias Burnus
Hi Paul,
Post by Paul Richard Thomas
This problem concerned associate targets being substrings. It turns
out that they are returned as pointer types (with a different cast for
unity based substrings ***sigh***) and so can be assigned directly to
the associate name. The patch quite simply removed the condition that
such targets be allocatable, pointer or dummy.
I noticed in the course of working up the testcase that
character (:), pointer :: ptr => NULL()
character (6), target :: tgt = 'lmnopq'
ptr => tgt
print *, len (ptr), ptr
end
ICEs on the NULL initialization of the pointer but works fine if this
is removed. Has this already been posted as a PR?
I leave it to Dominique to search for a PR; otherwise, I believe the
attach patch fixes the issue. – It just needs someone to package it with
a test case, regtest and commit it.
Post by Paul Richard Thomas
Bootstrapped and regtested on FC28/x86_64 - OK for trunk?
OK – thanks for the fix.
Tobias
Post by Paul Richard Thomas
PR fortran/58618
* trans-stmt.c (trans_associate_var): All strings that return
as pointer types can be assigned directly to the associate
name so remove 'attr' and the condition that uses it.
PR fortran/58618
* gfortran.dg/associate_45.f90 : New test.
--
"If you can't explain it simply, you don't understand it well enough"
- Albert Einstein
Loading...