[Patch, fortran] PR24223 and PR24705 - ping

Brooks Moses bmoses@stanford.edu
Wed Nov 16 19:12:00 GMT 2005


Paul Thomas wrote:
>>I could not immediately see the constraint on the second problem in 
>>the draft standard - however, Intel, DEC and g95 all signal the same 
>>error.
[...]
>>===================auto_internal_assumed.f90===============
>>
>>! { dg-do compile }
>>! Test fix of PR24705 - ICE on assumed character length
>>! internal function.
>>!
>>character (6) :: c
>> c = f1 ()        ! { dg-error "must not be assumed length" }
>> if (c .ne. 'abcdef') call abort
>>contains
>> function f1 ()
>>   character (*) :: f1
>>   f1 = 'abcdef'
>> end function f1
>>end

Fortran 95 Draft Standard, page 51, Section 5.1.1.5, on the Character 
type, lists the only ways a character length value of * can be used: 
dummy arguments of proceedures, named constants, and function results in 
external functions.  Internal function results are not on that list; 
ergo, not permitted.

(This could further be deduced from the fact that length(f1()) would be 
impossible to meaningfully define, and the Fortran standard usually 
doesn't allow obvious confusions like that.)

Incidentally, character length values of * are only permitted in 
function results of external functions with the provision that "any 
scoping unit invoking the function shall declare the function name with 
a character length parameter value other than * or access such a 
definition by host or use association," thereby explicitly associating a 
length with the result.  It may be worthwhile to write up some tests to 
confirm that gfortran properly checks for this (though it isn't required 
to, but it should at least not do really stupid things if length() is 
called on the result of one that is incompletely declared).

- Brooks



More information about the Gcc-patches mailing list