The following program seems to me to be valid Fortran 95, because the f95 standard 5.1.1.5 and 7.1.6.2 say a CHARACTER(n) declaration is OK if n is a scalar integer restricted expression, in which each primary is a constant, the intrinsic LEN is allowed, and so are pure functions that are not intrinsic, not internal, not statement functions, do not have dummy procedure arguments, and are not recursive. But gfortran won't compile it. Evidence:
[EMAIL PROTECTED] test system: ~/Jfh/Test 52 >cat testspec.f90 MODULE halvestring ! Can halfit be in a specification expression? CONTAINS PURE FUNCTION halfit(s1) RESULT (s2) CHARACTER(*),INTENT(IN):: s1 CHARACTER(len(s1)/2) :: s2 s2 = s1 END FUNCTION halfit END MODULE halvestring ! ----------- PROGRAM testspec USE halvestring CHARACTER(*),PARAMETER :: stringa = 'abcdeedcba' CHARACTER(len(halfit(stringa))) :: stringb stringb = halfit(stringa) PRINT "(I4,A)", len(stringb),' "'//stringb//'"' ! 5 "abcde" END PROGRAM testspec [EMAIL PROTECTED] test system: ~/Jfh/Test 53 >gfortran -v testspec.f90 Driving: gfortran -v testspec.f90 -lgfortranbegin -lgfortran -lm -shared-libgcc Using built-in specs. Target: i386-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=i386-redhat-linux Thread model: posix gcc version 4.1.1 20070105 (Red Hat 4.1.1-52) /usr/libexec/gcc/i386-redhat-linux/4.1.1/f951 testspec.f90 -quiet -dumpbase testspec.f90 -mtune=generic -auxbase testspec -version -I /usr/lib/gcc/i386-redhat-linux/4.1.1/finclude -o /tmp/ccUf0R9I.s GNU F95 version 4.1.1 20070105 (Red Hat 4.1.1-52) (i386-redhat-linux) compiled by GNU C version 4.1.1 20070105 (Red Hat 4.1.1-52). GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 In file testspec.f90:13 CHARACTER(len(halfit(stringa))) :: stringb 1 Error: 'stringb' at (1) must have constant character length in this context [EMAIL PROTECTED] test system: ~/Jfh/Test 54 > -- Summary: Pure function not allowed in specification expression Product: gcc Version: 4.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: john dot harper at vuw dot ac dot nz GCC build triplet: ? GCC host triplet: ? GCC target triplet: i386-redhat-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32386