* [Patch, fortran} pr68196 [4.9/5 Regression] ICE on function result with procedure pointer component
@ 2015-12-17 22:12 Paul Richard Thomas
2015-12-18 3:56 ` Steve Kargl
0 siblings, 1 reply; 4+ messages in thread
From: Paul Richard Thomas @ 2015-12-17 22:12 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 794 bytes --]
Dear All,
Some problems have come up that are not dissimilar to the original
bug, involving infinite recursion with procedure components, with the
same type as the containing type. The fix is verging on the trivial.
However, given that I found two further bugs in fixing the one
reported, I worry that there are more lurking nearby.
Bootstraps and regtests on x86_64 - OK for trunk and, in a couple of
weeks 5 and 4.9 branches?
Cheers
Paul
2015-12-17 Paul Thomas <pault@gcc.gnu.org>
PR fortran/68196
*expr.c (gfc_has_default_initializer): Prevent infinite recursion
through this function for procedure pointer components.
* trans-array.c (structure_alloc_comps): Ditto times two.
2015-12-17 Paul Thomas <pault@gcc.gnu.org>
PR fortran/68196
* gfortran.dg/proc_ptr_48.f90: New test.
[-- Attachment #2: check1712.diff --]
[-- Type: text/plain, Size: 2181 bytes --]
Index: gcc/fortran/expr.c
===================================================================
*** gcc/fortran/expr.c (revision 231253)
--- gcc/fortran/expr.c (working copy)
*************** gfc_has_default_initializer (gfc_symbol
*** 3930,3936 ****
for (c = der->components; c; c = c->next)
if (c->ts.type == BT_DERIVED)
{
! if (!c->attr.pointer
&& gfc_has_default_initializer (c->ts.u.derived))
return true;
if (c->attr.pointer && c->initializer)
--- 3930,3936 ----
for (c = der->components; c; c = c->next)
if (c->ts.type == BT_DERIVED)
{
! if (!c->attr.pointer && !c->attr.proc_pointer
&& gfc_has_default_initializer (c->ts.u.derived))
return true;
if (c->attr.pointer && c->initializer)
Index: gcc/fortran/trans-array.c
===================================================================
*** gcc/fortran/trans-array.c (revision 231253)
--- gcc/fortran/trans-array.c (working copy)
*************** structure_alloc_comps (gfc_symbol * der_
*** 8074,8080 ****
}
if (cmp_has_alloc_comps
! && !c->attr.pointer
&& !called_dealloc_with_status)
{
/* Do not deallocate the components of ultimate pointer
--- 8075,8081 ----
}
if (cmp_has_alloc_comps
! && !c->attr.pointer && !c->attr.proc_pointer
&& !called_dealloc_with_status)
{
/* Do not deallocate the components of ultimate pointer
*************** structure_alloc_comps (gfc_symbol * der_
*** 8264,8270 ****
components that are really allocated, the deep copy code has to
be generated first and then added to the if-block in
gfc_duplicate_allocatable (). */
! if (cmp_has_alloc_comps)
{
rank = c->as ? c->as->rank : 0;
tmp = fold_convert (TREE_TYPE (dcmp), comp);
--- 8265,8272 ----
components that are really allocated, the deep copy code has to
be generated first and then added to the if-block in
gfc_duplicate_allocatable (). */
! if (cmp_has_alloc_comps
! && !c->attr.proc_pointer)
{
rank = c->as ? c->as->rank : 0;
tmp = fold_convert (TREE_TYPE (dcmp), comp);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch, fortran} pr68196 [4.9/5 Regression] ICE on function result with procedure pointer component
2015-12-17 22:12 [Patch, fortran} pr68196 [4.9/5 Regression] ICE on function result with procedure pointer component Paul Richard Thomas
@ 2015-12-18 3:56 ` Steve Kargl
2015-12-18 9:28 ` Paul Richard Thomas
0 siblings, 1 reply; 4+ messages in thread
From: Steve Kargl @ 2015-12-18 3:56 UTC (permalink / raw)
To: Paul Richard Thomas; +Cc: fortran, gcc-patches
On Thu, Dec 17, 2015 at 11:12:17PM +0100, Paul Richard Thomas wrote:
>
> Some problems have come up that are not dissimilar to the original
> bug, involving infinite recursion with procedure components, with the
> same type as the containing type. The fix is verging on the trivial.
> However, given that I found two further bugs in fixing the one
> reported, I worry that there are more lurking nearby.
>
> Bootstraps and regtests on x86_64 - OK for trunk and, in a couple of
> weeks 5 and 4.9 branches?
>
OK.
Do you have a testcase that should also be committed?
--
Steve
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch, fortran} pr68196 [4.9/5 Regression] ICE on function result with procedure pointer component
2015-12-18 3:56 ` Steve Kargl
@ 2015-12-18 9:28 ` Paul Richard Thomas
0 siblings, 0 replies; 4+ messages in thread
From: Paul Richard Thomas @ 2015-12-18 9:28 UTC (permalink / raw)
To: Steve Kargl; +Cc: fortran, gcc-patches
Sorry, yes; proc_ptr_48.f90
! { dg-do run }
!
! Checks the fix for PR68196, comment #8
!
! Contributed by Damian Rouson <damian@sourceryinstitute.org>
!
type Bug ! Failed at trans--array.c:8269
real, allocatable :: scalar
procedure(boogInterface),pointer :: boog
end type
interface
function boogInterface(A) result(C)
import Bug
class(Bug) A
type(Bug) C
end function
end interface
real, parameter :: ninetynine = 99.0
real, parameter :: onenineeight = 198.0
type(bug) :: actual, res
actual%scalar = ninetynine
actual%boog => boogImplementation
res = actual%boog () ! Failed on bug in expr.c:3933
if (res%scalar .ne. onenineeight) call abort
! Make sure that the procedure pointer is assigned correctly
if (actual%scalar .ne. ninetynine) call abort
actual = res%boog ()
if (actual%scalar .ne. onenineeight) call abort
! Deallocate so that we can use valgrind to check for memory leaks
deallocate (res%scalar, actual%scalar)
contains
function boogImplementation(A) result(C) ! Failed at trans--array.c:8078
class(Bug) A
type(Bug) C
select type (A)
type is (bug)
C = A
C%scalar = onenineeight
class default
call abort
end select
end function
end
On 18 December 2015 at 04:56, Steve Kargl
<sgk@troutmask.apl.washington.edu> wrote:
> On Thu, Dec 17, 2015 at 11:12:17PM +0100, Paul Richard Thomas wrote:
>>
>> Some problems have come up that are not dissimilar to the original
>> bug, involving infinite recursion with procedure components, with the
>> same type as the containing type. The fix is verging on the trivial.
>> However, given that I found two further bugs in fixing the one
>> reported, I worry that there are more lurking nearby.
>>
>> Bootstraps and regtests on x86_64 - OK for trunk and, in a couple of
>> weeks 5 and 4.9 branches?
>>
>
> OK.
>
> Do you have a testcase that should also be committed?
>
> --
> Steve
--
Outside of a dog, a book is a man's best friend. Inside of a dog it's
too dark to read.
Groucho Marx
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch, fortran} pr68196 [4.9/5 Regression] ICE on function result with procedure pointer component
@ 2015-12-18 9:41 Paul Richard Thomas
0 siblings, 0 replies; 4+ messages in thread
From: Paul Richard Thomas @ 2015-12-18 9:41 UTC (permalink / raw)
To: Steve Kargl; +Cc: fortran, gcc-patches, Damian Rouson
Dear Steve,
Thanks - committed as revision 231807. I will have a poke around to
see if there are any more similar opportunities for infinite recursion
in trans-array.c (structure_alloc_comps). This turned out to be the
most difficult part of the patch for recursive allocatable components
(on hold until 7 branch) for rather obvious reasons; the solution
there is rather different since it is required that recursion occurs
on deallocation and this necessitates an explicit call to the
finalizer in structure_alloc_comps, instead of a call to itself.
Cheers
Paul
On 18 December 2015 at 04:56, Steve Kargl
<sgk@troutmask.apl.washington.edu> wrote:
> On Thu, Dec 17, 2015 at 11:12:17PM +0100, Paul Richard Thomas wrote:
>>
>> Some problems have come up that are not dissimilar to the original
>> bug, involving infinite recursion with procedure components, with the
>> same type as the containing type. The fix is verging on the trivial.
>> However, given that I found two further bugs in fixing the one
>> reported, I worry that there are more lurking nearby.
>>
>> Bootstraps and regtests on x86_64 - OK for trunk and, in a couple of
>> weeks 5 and 4.9 branches?
>>
>
> OK.
>
> Do you have a testcase that should also be committed?
>
> --
> Steve
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-12-18 9:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-17 22:12 [Patch, fortran} pr68196 [4.9/5 Regression] ICE on function result with procedure pointer component Paul Richard Thomas
2015-12-18 3:56 ` Steve Kargl
2015-12-18 9:28 ` Paul Richard Thomas
2015-12-18 9:41 Paul Richard Thomas
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).