[Bug fortran/40383] [4.5 Regression] incorrect bounds checking with optional character arguments

burnus at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Wed Jun 10 12:02:00 GMT 2009



------- Comment #4 from burnus at gcc dot gnu dot org  2009-06-10 12:02 -------
Patch -- I believe it does the right thing; especially, it preserves
backend_decl. If one copied the type earlier, the backend_decl would be
different and the backend does not like it, when the same type has different
declarations. (It still happens independent of this patch, but it makes sense
not to make the problem worse; cf. PR 38913. The "->next" should also be
correct, I think.

--- trans-decl.c        (revision 148340)
+++ trans-decl.c        (working copy)
@@ -1694,6 +1694,22 @@ create_function_arglist (gfc_symbol * sy
          gfc_finish_decl (length);

          /* Remember the passed value.  */
+          if (f->sym->ts.cl->passed_length != NULL)
+            {
+             /* This can happen if the same type is used for multiple
+                arguments. We need to copy cl as otherwise
+                cl->passed_length gets overwritten.  */
+             gfc_charlen *cl, *cl2;
+             cl = f->sym->ts.cl;
+             f->sym->ts.cl = gfc_get_charlen();
+             f->sym->ts.cl->length = cl->length;
+             f->sym->ts.cl->backend_decl = cl->backend_decl;
+             f->sym->ts.cl->length_from_typespec = cl->length_from_typespec;
+             f->sym->ts.cl->resolved = cl->resolved;
+             cl2 = f->sym->ts.cl->next;
+             f->sym->ts.cl->next = cl;
+              cl->next = cl2;
+            }
          f->sym->ts.cl->passed_length = length;

          /* Use the passed value for assumed length variables.  */


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40383



More information about the Gcc-bugs mailing list