diff mbox

fortran/65429 -- don't dereference a null pointer

Message ID 20150329162546.GA95666@troutmask.apl.washington.edu
State New
Headers show

Commit Message

Steve Kargl March 29, 2015, 4:25 p.m. UTC
On Sat, Mar 28, 2015 at 01:01:57AM +0100, Dominique Dhumieres wrote:
> 
> AFAICT your test succeeds without your patch and does not test that the ICE
> reported by FX is gone (indeed it is with your patch).
> 

New patch and testcase.  The ChangeLog entries are in the 
original email.  Built and tested on x86_64-*-freebsd.
OK, now?

Comments

Jerry DeLisle March 31, 2015, 5:17 p.m. UTC | #1
On 03/29/2015 09:25 AM, Steve Kargl wrote:
> On Sat, Mar 28, 2015 at 01:01:57AM +0100, Dominique Dhumieres wrote:
>>
>> AFAICT your test succeeds without your patch and does not test that the ICE
>> reported by FX is gone (indeed it is with your patch).
>>
>
> New patch and testcase.  The ChangeLog entries are in the
> original email.  Built and tested on x86_64-*-freebsd.
> OK, now?
>

OK Steve.
Steve Kargl April 7, 2015, 7:59 p.m. UTC | #2
On Tue, Mar 31, 2015 at 10:17:14AM -0700, Jerry DeLisle wrote:
> On 03/29/2015 09:25 AM, Steve Kargl wrote:
> > On Sat, Mar 28, 2015 at 01:01:57AM +0100, Dominique Dhumieres wrote:
> >>
> >> AFAICT your test succeeds without your patch and does not test that the ICE
> >> reported by FX is gone (indeed it is with your patch).
> >>
> >
> > New patch and testcase.  The ChangeLog entries are in the
> > original email.  Built and tested on x86_64-*-freebsd.
> > OK, now?
> >
> 
> OK Steve.

I just checked and this is not a regression with respect
to 4.6, 4.7. 4.8, or 4.9.  As 5.0 is coming soon, I'll
for stage 1 to commit.
Steve Kargl April 22, 2015, 11:18 p.m. UTC | #3
On Tue, Apr 07, 2015 at 12:59:20PM -0700, Steve Kargl wrote:
> On Tue, Mar 31, 2015 at 10:17:14AM -0700, Jerry DeLisle wrote:
> > On 03/29/2015 09:25 AM, Steve Kargl wrote:
> > > On Sat, Mar 28, 2015 at 01:01:57AM +0100, Dominique Dhumieres wrote:
> > >>
> > >> AFAICT your test succeeds without your patch and does not test that the ICE
> > >> reported by FX is gone (indeed it is with your patch).
> > >>
> > >
> > > New patch and testcase.  The ChangeLog entries are in the
> > > original email.  Built and tested on x86_64-*-freebsd.
> > > OK, now?
> > >
> > 
> > OK Steve.
> 
> I just checked and this is not a regression with respect
> to 4.6, 4.7. 4.8, or 4.9.  As 5.0 is coming soon, I'll
> for stage 1 to commit.
> 

Fixed with the following

r222342 trunk
r222343 5.1 branch
diff mbox

Patch

Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c	(revision 220943)
+++ gcc/fortran/decl.c	(working copy)
@@ -1404,9 +1404,7 @@  add_init_expr_to_sym (const char *name, 
 		    }
 		  else if (init->expr_type == EXPR_ARRAY)
 		    {
-		      gfc_constructor *c;
-		      c = gfc_constructor_first (init->value.constructor);
-		      clen = c->expr->value.character.length;
+		      clen = mpz_get_si (init->ts.u.cl->length->value.integer);
 		      sym->ts.u.cl->length
 				= gfc_get_int_expr (gfc_default_integer_kind,
 						    NULL, clen);
Index: gcc/testsuite/gfortran.dg/pr65429.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr65429.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/pr65429.f90	(working copy)
@@ -0,0 +1,19 @@ 
+! { dg-do run }
+! PR fortran/65429
+program foo
+
+   implicit none
+
+   character(*), parameter :: s(*) = [ character(5) :: 'abcde', 'fghij' ]
+   character(*), parameter :: t(*) = [ character(31) :: ]
+   character(*), parameter :: u(*) = [ 'qwerty', 'asdfgh', 'zxcvbn']
+   character(*), parameter :: v(*) = ['','']
+
+   if ((size(s) /= 2).or.(len(s)/=5)) call abort
+   if ((size(t) /= 0).or.(len(t)/=31)) call abort
+   if ((size(u) /= 3).or.(len(u)/=6)) call abort
+   if ((size(v) /= 2).or.(len(v)/=0)) call abort
+   if ((s(1)/='abcde').or.(s(2)/='fghij')) call abort
+   if ((u(1)/='qwerty').or.(u(2)/='asdfgh').or.(u(3)/='zxcvbn')) call abort
+
+end program foo