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

            Bug ID: 125393
           Summary: Wcharacter-truncation false positive for character
                    arrays
           Product: gcc
           Version: 16.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ajmay81 at gmail dot com
  Target Milestone: ---

Sending an element of a character array gets reported as sending a string
totalling the whole array size. Example:

module test
implicit none
contains

subroutine a(string)
character(len=2) string
end subroutine a

subroutine b
character(len=2) :: s1
character(len=2), dimension(2) :: s2
call a(s1)
call a(s2(1))
end subroutine b

end module test

This gives:

# > gfortran -c -Wcharacter-truncation test.f90
test.f90:13:7:

   13 | call a(s2(1))
      |       1
Warning: Character length of actual argument longer than of dummy argument
'string' (4/2) at (1) [-Wcharacter-truncation]

# > gfortran --version
GNU Fortran (SUSE Linux) 16.1.1 20260508

Reply via email to