https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119827
--- Comment #3 from kargls at comcast dot net --- (In reply to Visagan Ravindran from comment #2) > (In reply to kargls from comment #1) > > Perhaps, a review of the Fortran standard is in order. > > > > F2023, 9.4.1 > > > > R910 substring-range is [ scalar-int-expr ] : [ scalar-int-expr ] > > > > If the starting point is greater than the ending point, the substring > > has length zero; otherwise, both the starting point and the ending > > point shall be within the range 1, 2, ..., n. > > > > > > ! This does not raise a compilation or runtime error > > print *, 'MYSTR3= ', mystr(1:1-1) > > > > 1 > 0, so you have zero-length substrin > > > > ! This will not raise an error either... > > print *, 'MYSTR4= ', mystr(1:i-1) ! i-1=0 > > > > 1 > 0, so you have ... > > > > ! ... nor does this... > > i=-1 > > print *, 'MYSTR5= ', mystr(1:i) > > > > 1 > -1, so you have ... > > Thank you for your reply. A colleague informed me that the NAG compiler > picked this up as an error, but I suppose this is entirely in keeping with > the standard. I'm surprise that NAG issued an error. A warning might be appropriate. I edited the above F2023 quote to highlight the key sentence. The "otherwise" clause only applies after the determination of a zero-length string.