This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch, fortran] PR31251 Non-integer character length leads to segfault

:ADDPATCH fortran:

This is the second half of the fix for this bug. The first half fixed the segfault problem. This patch fixes the double error message.

It turns out that since the character specification was being matched for both a function prefix and a variable declaration, a character length was being added to the cl_list for both times. The error in the character length was then getting issued when cl_list is resolved, giving two error messages.

To fix this, I placed a check in decl.c (match_char_spec) to issue the error and exit before the bogus lengths are added to cl_list.

Bootstrapped on latest trunk and passes regression testing on x86-64-gnu-linux.

I will make a test case as appropriate.

OK for trunk?


2007-05-05 Jerry DeLisle <>

	PR fortran/31251
	* decl.c (match_char_spec): Add check for invalid character lengths.
Index: decl.c
*** decl.c	(revision 124460)
--- decl.c	(working copy)
*************** done:
*** 1634,1639 ****
--- 1634,1646 ----
        m = MATCH_ERROR;
+   if (m == MATCH_YES && seen_length == 1 && len != NULL
+       && len->ts.type != BT_INTEGER && len->ts.type != BT_UNKNOWN)
+     {
+       gfc_error ("Expression at %C must be of INTEGER type");
+       m = MATCH_ERROR;
+     }
    if (m != MATCH_YES)
        gfc_free_expr (len);
  character(len=2.3) :: s
  print *, len(s)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]