-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Closed
Closed
Copy link
Labels
Description
Consider the following three programs. These are all invalid.
test1.f90
character(len=5) :: s
s = "flang"
print*, "s:", s(-1111111111111111111:4)
endtest2.f90
character(len=5) :: s
s = "flang"
print*, "s:", s(-11111111111111111111:4)
endtest3.f90
character(len=5) :: s
s = "flang"
print*, "s:", s(-111111111111111111111:4)
endGfortran rejects the above three programs with the same message.
$ gfortran test1.f90
test1.f90:3:16:
3 | print*, "s:", s(-1111111111111111111:4)
| 1
Error: Syntax error in PRINT statement at (1)
$ gfortran test2.f90
test2.f90:3:16:
3 | print*, "s:", s(-11111111111111111111:4)
| 1
Error: Syntax error in PRINT statement at (1)
$ gfortran test3.f90
test3.f90:3:16:
3 | print*, "s:", s(-111111111111111111111:4)
| 1
Error: Syntax error in PRINT statement at (1)With flang-new, I got the following results.
$ flang-new test1.f90
error: Semantic errors in test1.f90
./test1.f90:3:15: error: Substring must begin at 1 or later, not -1111111111111111111
print*, "s:", s(-1111111111111111111:4)
^^^^^^^^^^^^^^^^^^^^^^^^^
$ flang-new test2.f90
./test2.f90:3:15: warning: INTEGER(16) to INTEGER(8) conversion overflowed
print*, "s:", s(-11111111111111111111:4)
^^^^^^^^^^^^^^^^^^^^^^^^^^
$ ./a.out
s:
$ flang-new test3.f90
error: Semantic errors in test3.f90
./test3.f90:3:15: warning: INTEGER(16) to INTEGER(8) conversion overflowed
print*, "s:", s(-111111111111111111111:4)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
./test3.f90:3:15: error: Substring must begin at 1 or later, not -430646668853801415
print*, "s:", s(-111111111111111111111:4)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
./test3.f90:3:15: warning: INTEGER(16) to INTEGER(8) conversion overflowed
print*, "s:", s(-111111111111111111111:4)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
./test3.f90:3:15: error: Substring must begin at 1 or later, not -430646668853801415
print*, "s:", s(-111111111111111111111:4)
^^^^^^^^^^^^^^^^^^^^^^^^^^^It seems more consistent for test2.f90 and test3.f90 to be rejected with the same error message as test1.f90. Also, the error message for test3.f90 is incorrect because the number -430646668853801415 does not exist in test3.f90.