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

            Bug ID: 101917
           Summary: Spurious -Wstringop-overread with -flto when passing
                    zero sized arrays
           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.c
void bar_(const int flag[], const int *num) { }

$ cat foo.f90
program foo
integer :: idummy(0)
call bar(idummy, 0)
end program

$ gcc -flto -c bar.c
$ gfortran -Wall -Wextra -flto -c foo.f90
$ gfortran -Wall -Wextra -flto foo.o bar.o
foo.f90: In function 'foo':
foo.f90:3:19: warning: 'bar_' reading 4 bytes from a region of size 0
[-Wstringop-overread]
    3 | call bar(idummy, 0)
      |                   ^
foo.f90:3:19: note: referencing argument 1 of type 'const int *'
bar.c:1:6: note: in a call to function 'bar_'
    1 | void bar_(const int flag[], const int *num) { }
      |      ^

Reply via email to