https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101827
Bug ID: 101827 Summary: Wrong stringop-overflow warning Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: jellby at yahoo dot com Target Milestone: --- When trying to compile OpenMolcas with gcc 10.1 and link-time optimization I get: ../src/slapaf_util/outofplane_list.f: In function ‘outofplane_list’: ../src/slapaf_util/outofplane_list.f:524: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=] 524 | Lbls(3)(iE3+1:iE3+1)='(' | ../src/slapaf_util/outofplane_list.f:45:32: note: at offset 0 to object ‘lbls’ with size 40 declared here 45 | Character*(LENIN4) Lbls(4) | ^ [...] lto1: all warnings being treated as errors lto-wrapper: fatal error: /usr/bin/gfortran returned 1 exit status How is "Lbls(3)(iE3+1:iE3+1)" a region of size 0? Similar constructs elsewhere don't raise the flag. Does the compiler believe "iE3+1" is beyond the length of the string? But then it says nothing without -flto.