The following code:

program abs_test1
   implicit none
   intrinsic cdabs

!   write(*,*) cdabs((4,3)) ! Causes ICE, as well
   call sub(cdabs)
end program abs_test1

subroutine sub(f)
   implicit none
   interface
      elemental function f(x)
         complex(kind(1.0d0)), intent(in) :: x
         real(kind(x)) :: f
      end function f
   end interface
   complex(kind(1.0d0)) x

   x = (4,3)
   write(*,*) f(x)
end subroutine sub


has an incorrect behavior when -std=f95 is specified (according to James Van
Buskirk, see
http://home.comcast.net/~kmbtib/gfortran_bugs/REF_JVB_GFTN_003.html). On
powerpc-apple-darwin, I get:

$ gfortran abs_test1.f90 && ./a.out
   5.00000000000000     
$ gfortran abs_test1.f90 -std=f95 && ./a.out
   2.25000000000000     

while on i686-mingw:

$ gfortran abs_test1.f90 && ./a.out
        5.00000000000000     
$ gfortran abs_test1.f90 -std=f95 && ./a.out
        NaN


Another related issue: when uncommenting the commented line, the behavior is
correct without -std=f95 (error issued at compile-time), but -std=f95 causes 
ICE:

$ gfortran abs_test1.f90 -std=f95 && ./a.out
abs_test1.f90: In function 'MAIN__':
abs_test1.f90:12: internal compiler error: in gfc_typenode_for_spec, at
fortran/trans-types.c:613

-- 
           Summary: cdabs intrinsic incorrectly handled with -std=f95
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: coudert at clipper dot ens dot fr
                CC: gcc-bugs at gcc dot gnu dot org


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

Reply via email to