https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119827
--- Comment #5 from Visagan Ravindran <v2000kiara at gmail dot com> --- (In reply to anlauf from comment #4) > (In reply to kargls from comment #3) > > (In reply to Visagan Ravindran from comment #2) > > > 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. > > Which NAG version gives an error? Which compiler flags? > > I tried: > > NAG Fortran Compiler Release 7.2(Shin-Urayasu) Build 7200 > > and even with -C=all it did not give any errors. I just went back to look at the error logs from the CI tests with NAG on the actual code and it was actually an error on the starting index or lower bound (which is also picked up by gfortran). I regrettably don't have a copy of NAG myself. I was merely surprised in the course of debugging this that gfortran did not pick up the upper bound on a substring (although it does for arrays), although in light of kargls's comment, this is normal behaviour with regards to the standard.