In file strpresent.F90:

program test_string_present

    call test_present(1, "foo")
    call test_present(2)

end program

subroutine test_present(a, b)
    integer :: a
    character*(*), optional :: b

    if (present(b)) then
        write (0,*) "b is present."
    else
        write (0,*) "b is not present."
    end if

end subroutine test_present

As of SVN revision 115597, this yields the output:

 b is present.
 b is present.

It appears that the present() intrinsic function isn't working correctly for
optional character strings.

Ifort yields the expected output:

 b is present.
 b is not present.

The output of gfortran -v -save-temps -o strpresent strpresent.F90:

Driving: gfortran -v -save-temps -o strpresent strpresent.F90 -lgfortranbegin
-lgfortran -lm -shared-libgcc
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /home/pfarrell/redhat/BUILD/gcc4-115597/configure
--prefix=/opt/packages/gcc4 --enable-bootstrap --enable-languages=c,c++,fortran
Thread model: posix
gcc version 4.2.0 20060719 (experimental)
 /opt/packages/gcc4/libexec/gcc/i686-pc-linux-gnu/4.2.0/cc1 -E -lang-fortran
-traditional-cpp -D_LANGUAGE_FORTRAN -quiet -v strpresent.F90 -mtune=generic
-fpch-preprocess -o strpresent.f95
ignoring nonexistent directory
"/opt/packages/gcc4/lib/gcc/i686-pc-linux-gnu/4.2.0/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /opt/packages/gcc4/include
 /opt/packages/gcc4/lib/gcc/i686-pc-linux-gnu/4.2.0/include
 /usr/include
End of search list.
 /opt/packages/gcc4/libexec/gcc/i686-pc-linux-gnu/4.2.0/f951 strpresent.f95
-ffree-form -quiet -dumpbase strpresent.F90 -mtune=generic -auxbase strpresent
-version -fpreprocessed -I
/opt/packages/gcc4/lib/gcc/i686-pc-linux-gnu/4.2.0/finclude -o strpresent.s
GNU F95 version 4.2.0 20060719 (experimental) (i686-pc-linux-gnu)
        compiled by GNU C version 4.2.0 20060719 (experimental).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
 as -V -Qy -o strpresent.o strpresent.s
GNU assembler version 2.15.92.0.2 (i386-redhat-linux) using BFD version
2.15.92.0.2 20040927
 /opt/packages/gcc4/libexec/gcc/i686-pc-linux-gnu/4.2.0/collect2 --eh-frame-hdr
-m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o strpresent /usr/lib/crt1.o
/usr/lib/crti.o /opt/packages/gcc4/lib/gcc/i686-pc-linux-gnu/4.2.0/crtbegin.o
-L/opt/packages/gcc4/lib/gcc/i686-pc-linux-gnu/4.2.0
-L/opt/packages/gcc4/lib/gcc/i686-pc-linux-gnu/4.2.0/../../.. strpresent.o
-lgfortranbegin -lgfortran -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
/opt/packages/gcc4/lib/gcc/i686-pc-linux-gnu/4.2.0/crtend.o /usr/lib/crtn.o


-- 
           Summary: gfortran does not implement the present intrinsic
                    procedure correctly for optional character strings
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: cyan+gcc at compsoc dot nuigalway dot ie
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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

Reply via email to