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

            Bug ID: 101918
           Summary: LTO type mismatches for runtime library functions in
                    mixed -fdefault-real-8 projects
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rimvydas.jas at gmail dot com
  Target Milestone: ---

$ cat bar.f90
program bar
implicit none
logical :: mask(2,3)
integer :: ai(2,3), vi(5)
real :: ar(2,3), vr(2)
double precision :: ad(2,3), vd(2)
ai = 0
ai(1,1:2) = (/ 1, 2 /)
ar = ai
ad = ai
mask = ai .ne. 0
vi = PACK(ai, ai .gt. 0, vector=(/1,2,3,4,5/))
vd = PACK(ad, mask)
vr = PACK(ar, mask)
call foo()
end program

$ cat foo.f90
subroutine foo
implicit none
real :: ar(2,3), v(1)
ar = 0.
ar(1,1) = 1.
v = PACK(ar, ar > 0.)
end subroutine

$ gfortran -Wall -Wextra -flto -fdefault-real-8 -c foo.f90
$ gfortran -flto -Wall -Wextra foo.o bar.f90
bar.f90:14:19: warning: type of '_gfortran_pack' does not match original
declaration [-Wlto-type-mismatch]
   14 | vr = PACK(ar, mask)
      |                   ^
bar.f90:13:19: warning: type of '_gfortran_pack' does not match original
declaration [-Wlto-type-mismatch]
   13 | vd = PACK(ad, mask)
      |                   ^
bar.f90:12:46: warning: type of '_gfortran_pack' does not match original
declaration [-Wlto-type-mismatch]
   12 | vi = PACK(ai, ai .gt. 0, vector=(/1,2,3,4,5/))
      |                                              ^
foo.f90:6:21: note: '_gfortran_pack' was previously declared here
    6 | v = PACK(ar, ar > 0.)
      |                     ^
foo.f90:6:21: note: code may be misoptimized unless '-fno-strict-aliasing' is
used

In medium sized mixed C/Fortran codebase there are more instances for:
 _gfortran_matmul_r8
 _gfortran_pack
 _gfortran_reshape_r8
 _gfortran_set_convert
 _gfortran_shape_4
 _gfortran_unpack0
 _gfortran_unpack1

Does this mean -flto cannot be used in mixed -fdefault-real-8 and usual modes?

Reply via email to