[Bug fortran/34429] Fails: character(len=use_associated_const) function foo()

pault at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Thu Jan 17 10:53:00 GMT 2008



------- Comment #3 from pault at gcc dot gnu dot org  2008-01-17 10:12 -------
Fixed on trunk - see below for some remaining wrinkles, dug up by Tobias.  I
will keep this pR open until both are fixed.

Paul

wrinkle #1:  This one is easily fixed.

Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c  (révision 131592)
+++ gcc/fortran/decl.c  (copie de travail)
@@ -2156,6 +2156,7 @@
      after the specification statements.  */
   if (gfc_matching_function
        && !(len && len->expr_type != EXPR_VARIABLE
+                && len->expr_type != EXPR_CONSTANT
                 && len->expr_type != EXPR_OP))
     {
       gfc_undo_symbols ();

module m
 integer, parameter :: l = 2
end module m

program test
 implicit none
 integer, parameter :: l = 5
 character(len=10) :: c
 c = f()
contains
 character(len=l) function f()
   use m
   print *, len(f)
! if (len(f) /= 2) call abort  ! gives 5 right now...
   f = "a"
 end function f
end program test
! { dg-final { cleanup-modules "m" } }

wrinkle #2:  This one is proving to be a bit recalcitrant.

module m
 character(2) :: l
end module m

 implicit none
!  character(4) :: l
 print *, f()
contains
 character(len=len(l)) function f()
   use m
   f = "4"
   if (len(f)==2) f= "2"
 end function f
end

where 'l' is found to be ambiguous; this must arise because the first match of
the length is leaving the symbol intact.


-- 


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



More information about the Gcc-bugs mailing list