[Patch, fortran] PR57033 ICE on extended derived type and default initialization

2014-02-01 Thread Mikael Morin
Hello,

here is a fix for PR57033.
The problem was gfc_convert_to_structure_constructor calling itself
recursively and changing `actual' behind its back without going through
the loop condition.
The fix is pretty obvious; I thought there was something missing (see
the PR) but on second thought, it seems to be correct.

regression tested on x86_64-unknown-linux-gnu; OK for trunk and then
4.8/4.7?

Mikael

2014-01-26  Mikael Morin  mik...@gcc.gnu.org

PR fortran/57033
* primary.c (gfc_convert_to_structure_constructor): Avoid null pointer
dereference.

2014-01-26  Mikael Morin  mik...@gcc.gnu.org

PR fortran/57033
* gfortran.dg/default_initialization_7.f90: New test.

diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c
index c77b4ec..7d7fbad 100644
--- a/gcc/fortran/primary.c
+++ b/gcc/fortran/primary.c
@@ -2544,7 +2544,8 @@ gfc_convert_to_structure_constructor (gfc_expr *e, gfc_symbol *sym, gfc_expr **c
   if (parent  !comp)
 	break;
 
-  actual = actual-next;
+  if (actual)
+	actual = actual-next;
 }
 
   if (!build_actual_constructor (comp_head, ctor_head, sym))

! { dg-do compile }
!
! PR fortran/57033
! ICE on a structure constructor of an extended derived type whose parent
! type last component has a default initializer
!
! Contributed by Tilo Schwarz t...@tilo-schwarz.de

program ice

type m
integer i
logical :: f = .false.
end type m

type, extends(m) :: me
end type me

type(me) meo

meo = me(1)  ! ICE
end program ice



Re: [Patch, fortran] PR57033 ICE on extended derived type and default initialization

2014-02-01 Thread Paul Richard Thomas
Dear Mikael,

We seem to be breaking records tonight :-)

OK by me for trunk, 4.7 and 4.8.

Thanks!

Paul

On 1 February 2014 19:49, Mikael Morin mikael.mo...@sfr.fr wrote:
 Hello,

 here is a fix for PR57033.
 The problem was gfc_convert_to_structure_constructor calling itself
 recursively and changing `actual' behind its back without going through
 the loop condition.
 The fix is pretty obvious; I thought there was something missing (see
 the PR) but on second thought, it seems to be correct.

 regression tested on x86_64-unknown-linux-gnu; OK for trunk and then
 4.8/4.7?

 Mikael




-- 
The knack of flying is learning how to throw yourself at the ground and miss.
   --Hitchhikers Guide to the Galaxy