https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93871

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #2 from kargl at gcc dot gnu.org ---
Can you post the code you used for testing?  Your patch to simplify.c
affects compile-time constant folding.  simplify.c has nothing to do
with a run-time evaluation.

Hmmm, upon inspection, the implementation of cotan in the Fortran FE
is certainly broken.

function foo(z) result(a)
   complex a
   complex, intent(in) :: z
   intrinsic cotan
   a = cotan(z)
end function foo

% gfcx -c a.f90
a.f90:4:18:

    4 |    intrinsic cotan
      |                  1
Error: 'cotan' declared INTRINSIC at (1) does not exist

Removing the 'intrinsic cotan' line and running in the debugger,
one finds that none of gfc_check_fn_rc2008, gfc_simplify_cotan,
and gfc_resolve_cotan are called.  So, compiling this to assembly

% gfcx -S -o a.s -O -c a.f90


        .cfi_startproc
        pushq   %rbp
        .cfi_def_cfa_offset 16
        .cfi_offset 6, -16
        movq    %rsp, %rbp
        .cfi_def_cfa_register 6
        subq    $16, %rsp
        call    cotan_
        movss   %xmm0, -8(%rbp)
        movl    $0x00000000, -4(%rbp)
        movq    -8(%rbp), %xmm0
        leave
        .cfi_def_cfa 7, 8
        ret
        .cfi_endproc

we see that we're calling a function named cotan.  Haven't found
where cotan lives.

% nm /usr/local/lib/gcc9/libgfortran.a | grep cotan
nm: bessel_r10.o: no symbols
nm: atomic.o: no symbols
% nm /usr/lib/libm.a | grep cotan
% find ~/gcc/gccx/libgfortran -type f | xargs grep -i cotan

Completely the program

program bar
  complex b, c
  b = (1.,1.)
  c = cotan(b)
  print *, c
end program bar

% gfcx -o z a.f90
/usr/local/bin/ld: /tmp/ccqbsxb5.o: in function `MAIN__':
a.f90:(.text+0x2d): undefined reference to `cotan_'
collect2: error: ld returned 1 exit status

Reply via email to