https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97272
Bug ID: 97272 Summary: Wrong answer from MAXLOC with character arg Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: longb at cray dot com Target Milestone: --- Test case: > cat test.f90 program test character, allocatable :: a(:) integer(8) l, i l = 2000000_8 allocate (a(l)) do i = 1, l a(i) = 'a' end do l = l - 1 a(l) = 'b' i = maxloc (a, dim=1, kind=8) print *, 'i = ', i, 'a(i) = ', a(i) end Expected behavior (Cray): > ftn test.f90 > ./a.out i = 1999999 a(i) = b Incorrect result (gfortran): > module swap PrgEnv-cray PrgEnv-gnu > gfortran test.f90 > ./a.out i = 2000000 a(i) = a > gfortran --version GNU Fortran (GCC) 10.1.0 20200507 (Cray Inc.) Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.