[Bug fortran/85130] Substrings out of range are not rejected
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85130 anlauf at gcc dot gnu.org changed: What|Removed |Added Target Milestone|--- |9.5 Resolution|--- |FIXED Status|ASSIGNED|RESOLVED --- Comment #11 from anlauf at gcc dot gnu.org --- Fixed on all open branches. Closing.
[Bug fortran/85130] Substrings out of range are not rejected
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85130 --- Comment #10 from CVS Commits --- The releases/gcc-9 branch has been updated by Harald Anlauf : https://gcc.gnu.org/g:0fabf86a52c46db19026a956cf386da46fa4d0be commit r9-9738-g0fabf86a52c46db19026a956cf386da46fa4d0be Author: Harald Anlauf Date: Mon Sep 13 19:26:35 2021 +0200 Fortran - fix handling of substring start and end indices gcc/fortran/ChangeLog: PR fortran/85130 * expr.c (find_substring_ref): Handle given substring start and end indices as signed integers, not unsigned. gcc/testsuite/ChangeLog: PR fortran/85130 * gfortran.dg/substr_6.f90: Revert commit r8-7574, adding again test that was erroneously considered as illegal. (cherry picked from commit 8d93ba93d3b13ac3d3c34404cad87732c809605b)
[Bug fortran/85130] Substrings out of range are not rejected
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85130 --- Comment #9 from CVS Commits --- The releases/gcc-10 branch has been updated by Harald Anlauf : https://gcc.gnu.org/g:a1591a283767168982ff60414ee01aaa1400fbf8 commit r10-10142-ga1591a283767168982ff60414ee01aaa1400fbf8 Author: Harald Anlauf Date: Mon Sep 13 19:26:35 2021 +0200 Fortran - fix handling of substring start and end indices gcc/fortran/ChangeLog: PR fortran/85130 * expr.c (find_substring_ref): Handle given substring start and end indices as signed integers, not unsigned. gcc/testsuite/ChangeLog: PR fortran/85130 * gfortran.dg/substr_6.f90: Revert commit r8-7574, adding again test that was erroneously considered as illegal. (cherry picked from commit 8d93ba93d3b13ac3d3c34404cad87732c809605b)
[Bug fortran/85130] Substrings out of range are not rejected
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85130 --- Comment #8 from CVS Commits --- The releases/gcc-11 branch has been updated by Harald Anlauf : https://gcc.gnu.org/g:3bc4ed085145e1cb6089841c811094633eea7431 commit r11-9009-g3bc4ed085145e1cb6089841c811094633eea7431 Author: Harald Anlauf Date: Mon Sep 13 19:26:35 2021 +0200 Fortran - fix handling of substring start and end indices gcc/fortran/ChangeLog: PR fortran/85130 * expr.c (find_substring_ref): Handle given substring start and end indices as signed integers, not unsigned. gcc/testsuite/ChangeLog: PR fortran/85130 * gfortran.dg/substr_6.f90: Revert commit r8-7574, adding again test that was erroneously considered as illegal. (cherry picked from commit 8d93ba93d3b13ac3d3c34404cad87732c809605b)
[Bug fortran/85130] Substrings out of range are not rejected
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85130 --- Comment #7 from CVS Commits --- The master branch has been updated by Harald Anlauf : https://gcc.gnu.org/g:8d93ba93d3b13ac3d3c34404cad87732c809605b commit r12-3499-g8d93ba93d3b13ac3d3c34404cad87732c809605b Author: Harald Anlauf Date: Mon Sep 13 19:26:35 2021 +0200 Fortran - fix handling of substring start and end indices gcc/fortran/ChangeLog: PR fortran/85130 * expr.c (find_substring_ref): Handle given substring start and end indices as signed integers, not unsigned. gcc/testsuite/ChangeLog: PR fortran/85130 * gfortran.dg/substr_6.f90: Revert commit r8-7574, adding again test that was erroneously considered as illegal.
[Bug fortran/85130] Substrings out of range are not rejected
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85130 --- Comment #6 from anlauf at gcc dot gnu.org --- Submitted: https://gcc.gnu.org/pipermail/fortran/2021-September/056500.html
[Bug fortran/85130] Substrings out of range are not rejected
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85130 anlauf at gcc dot gnu.org changed: What|Removed |Added Assignee|unassigned at gcc dot gnu.org |anlauf at gcc dot gnu.org Status|NEW |ASSIGNED --- Comment #5 from anlauf at gcc dot gnu.org --- We should handle the substring bounds as signed instead of unsigned. This is obviously fixed by: diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index dfecc3012e1..604e63e6164 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -1724,8 +1724,8 @@ find_substring_ref (gfc_expr *p, gfc_expr **newp) *newp = gfc_copy_expr (p); free ((*newp)->value.character.string); - end = (gfc_charlen_t) mpz_get_ui (p->ref->u.ss.end->value.integer); - start = (gfc_charlen_t) mpz_get_ui (p->ref->u.ss.start->value.integer); + end = (gfc_charlen_t) mpz_get_si (p->ref->u.ss.end->value.integer); + start = (gfc_charlen_t) mpz_get_si (p->ref->u.ss.start->value.integer); if (end >= start) length = end - start + 1; else and regtests cleanly. :-) @Thomas: although the wording is slightly different between F2003 and F2018, it always results in length zero if the starting point exceeds the ending point. Would you agree in reverting your commit r258976 after applying the above?
[Bug fortran/85130] Substrings out of range are not rejected
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85130 anlauf at gcc dot gnu.org changed: What|Removed |Added Keywords||wrong-code CC||anlauf at gcc dot gnu.org --- Comment #4 from anlauf at gcc dot gnu.org --- F2018 has the following changed text in 9.4.1 Substrings: ... 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. ... Thus the following code would be legal: character(5), parameter :: c0(1) = [ "12345" ] print *, c0(1)(-5:-8) end and print an empty string, while it currently prints junk. It does the right thing with current trunk when parameter is removed, though.
[Bug fortran/85130] Substrings out of range are not rejected
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85130 Dominique d'Humieres changed: What|Removed |Added Priority|P4 |P5
[Bug fortran/85130] Substrings out of range are not rejected
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85130 Dominique d'Humieres changed: What|Removed |Added Priority|P3 |P4 Status|UNCONFIRMED |NEW Last reconfirmed||2018-03-30 Ever confirmed|0 |1 --- Comment #3 from Dominique d'Humieres --- Confirmed.
[Bug fortran/85130] Substrings out of range are not rejected
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85130 Thomas Koenig changed: What|Removed |Added Blocks|84094 | Severity|normal |enhancement --- Comment #2 from Thomas Koenig --- Test suite bug is corrected, the underlying accepts-invalid is still there. This is not a constraint, so marking as enhancement. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84094 [Bug 84094] several correctness issues in gfortran.dg
[Bug fortran/85130] Substrings out of range are not rejected
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85130 --- Comment #1 from Thomas Koenig --- Author: tkoenig Date: Fri Mar 30 12:18:30 2018 New Revision: 258976 URL: https://gcc.gnu.org/viewcvs?rev=258976=gcc=rev Log: 2018-03-30 Thomas KoenigPR fortran/85130 * gfortran.dg/substr_6.f90: Remove illegal test for out-of-bounds substring. Modified: trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gfortran.dg/substr_6.f90