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

--- Comment #8 from Rimvydas (RJ) <rimvydas.jas at gmail dot com> ---
If we can agree that use of -fdefault-real-8 -fdefault-double-8 with -flto does
not magically recompile intrinsic subroutines in runtime libgfortran.so
library, it looks like it is a frontend issue not providing correct information
for LTO.  Somewhat more trivial example for different intrinsic runtime call:
$ cat foo.f90
program foo
implicit none
double precision, dimension (1:4) :: b = 1
double precision, dimension (1:2, 1:2) :: h
h = reshape( b, (/ 2, 2 /))
call bar()
end program

$ cat bar.f90
subroutine bar
implicit none
real, dimension (1:4) :: b = 1
real, dimension (1:2, 1:2) :: h
h = reshape( b, (/ 2, 2 /))
end subroutine

$ gfortran -Wall -Wextra -flto -fdefault-real-8 -fdefault-double-8 -c bar.f90
$ gfortran -Wall -Wextra -flto foo.f90 bar.o
bar.f90:5:27: warning: type of '_gfortran_reshape_r8' does not match original
declaration [-Wlto-type-mismatch]
    5 | h = reshape( b, (/ 2, 2 /))
      |                           ^
foo.f90:5:27: note: '_gfortran_reshape_r8' was previously declared here
    5 | h = reshape( b, (/ 2, 2 /))
      |                           ^
foo.f90:5:27: note: code may be misoptimized unless '-fno-strict-aliasing' is
used

The -fdump-tree-original match exactly and both report: _gfortran_reshape_r8/4
function body not available.  The same happens even when bar.f90 is using
real(c_double) from ISO_C_BINDINGS.
Maybe it would be possible to provide interfaces for calls to intrinsics in the
runtime library, even if that would require use of "!GCC$ ATTRIBUTES
NO_ARG_CHECK :: VARIABLE" like it is already done for "USE MPI" bindings?

Reply via email to