Hi Harald,

the attached patch is pretty much self-explaining: check for bounds violation
when initializing a substring in a data statement and treat the resulting error.

If more detailed information should be emitted with the error message, I'm
open for suggestions.

Currently, we issue these error messages in similar circumstances:

$ cat a.f90
  character (len=3) :: a
  a = 'abc'
  print a(0:3)
  print a(1:4)
end program
$ gfortran a.f90
a.f90:3:10:

    3 |   print a(0:3)
      |          1
Error: Substring start index at (1) is less than one
a.f90:4:10:

    4 |   print a(1:4)
      |          1
Error: Substring end index at (1) exceeds the string length

Could you maybe just re-use these?

Regtested on x86_64-pc-linux-gnu.

OK for master?

OK with adjusted error message.  Thanks for the patch!

Best regards

        Thomas

Reply via email to