[Bug fortran/78758] [7 Regression] Warning: '__builtin_memcpy' ... overflows the destination for string assignment

anlauf at gmx dot de gcc-bugzilla@gcc.gnu.org
Fri Dec 9 21:59:00 GMT 2016


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

--- Comment #1 from Harald Anlauf <anlauf at gmx dot de> ---
Slightly reduced variant:

integer function get_satid (name)
  character(len=*), intent(in) :: name
  character(len=16)            :: longname
  integer, external            :: satid_longname

! longname(1:) = " " // adjustl (name(1:)) ! No warning
  longname(2:) = " " // adjustl (name(2:)) ! Warning
  get_satid = satid_longname (longname)
end function get_satid

produces:

gfcbug137.f90:7:0:

   longname(2:) = " " // adjustl (name(2:)) ! Warning

Warning: '__builtin_memcpy' writing 15 bytes into a region of size 14 overflows
the destination [-Wstringop-overflow=]

I looked at the dump tree differences for the two variants indicated above,
but frankly, I do not understand what's going on here.


More information about the Gcc-bugs mailing list