[Bug fortran/93714] [8/9/10 Regression] ICE in gfc_check_same_strlen, at fortran/check.c:1253
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93714 markeggleston at gcc dot gnu.org changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #6 from markeggleston at gcc dot gnu.org --- Committed to master and backported to gcc 8 and gcc 9 branches.
[Bug fortran/93714] [8/9/10 Regression] ICE in gfc_check_same_strlen, at fortran/check.c:1253
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93714 --- Comment #5 from CVS Commits --- The releases/gcc-8 branch has been updated by Mark Eggleston : https://gcc.gnu.org/g:db0e1e9948434352455db1e729383272d79105e8 commit r8-10037-gdb0e1e9948434352455db1e729383272d79105e8 Author: Mark Eggleston Date: Wed Feb 19 10:30:38 2020 + [fortran] ICE assign character pointer to non target PR93714 An ICE occurred if an attempt was made to assign a pointer to a character variable that has an length incorrectly specified using a real constant and does not have the target attribute. Backported from mainline 2020-02-18 Mark Eggleston PR fortran/93714 * expr.c (gfc_check_pointer_assign): Move check for matching character length to after checking the lvalue attributes for target or pointer. PR fortran/93714 * gfortran.dg/char_pointer_assign_6.f90: Look for no target message instead of length mismatch. * gfortran.dg/pr93714_1.f90 * gfortran.dg/pr93714_2.f90
[Bug fortran/93714] [8/9/10 Regression] ICE in gfc_check_same_strlen, at fortran/check.c:1253
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93714 --- Comment #4 from CVS Commits --- The releases/gcc-9 branch has been updated by Mark Eggleston : https://gcc.gnu.org/g:44ea6508f1009086018d0db4347a14b9c4eec2c0 commit r9-8256-g44ea6508f1009086018d0db4347a14b9c4eec2c0 Author: Mark Eggleston Date: Wed Feb 19 09:36:42 2020 + [Fortran] ICE assign character pointer to non target PR93714 An ICE occurred if an attempt was made to assign a pointer to a character variable that has an length incorrectly specified using a real constant and does not have the target attribute. Backported from mainline 2020-02-18 Mark Eggleston PR fortran/93714 * expr.c (gfc_check_pointer_assign): Move check for matching character length to after checking the lvalue attributes for target or pointer. PR fortran/93714 * gfortran.dg/char_pointer_assign_6.f90: Look for no target message instead of length mismatch. * gfortran.dg/pr93714_1.f90 * gfortran.dg/pr93714_2.f90
[Bug fortran/93714] [8/9/10 Regression] ICE in gfc_check_same_strlen, at fortran/check.c:1253
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93714 --- Comment #3 from CVS Commits --- The master branch has been updated by Mark Eggleston : https://gcc.gnu.org/g:06119d691e27e25fd4f4486467ad95f7b545fde3 commit r10-6703-g06119d691e27e25fd4f4486467ad95f7b545fde3 Author: Mark Eggleston Date: Tue Feb 18 15:54:13 2020 + [fortran] ICE assign character pointer to non target PR93714 An ICE occurred if an attempt was made to assign a pointer to a character variable that has an length incorrectly specified using a real constant and does not have the target attribute. gcc/fortran/ChangeLog PR fortran/93714 * expr.c (gfc_check_pointer_assign): Move check for matching character length to after checking the lvalue attributes for target or pointer. gcc/testsuite/ChangeLog PR fortran/93714 * gfortran.dg/char_pointer_assign_6.f90: Look for no target message instead of length mismatch. * gfortran.dg/pr93714_1.f90 * gfortran.dg/pr93714_2.f90
[Bug fortran/93714] [8/9/10 Regression] ICE in gfc_check_same_strlen, at fortran/check.c:1253
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93714 markeggleston at gcc dot gnu.org changed: What|Removed |Added CC||markeggleston at gcc dot gnu.org --- Comment #2 from markeggleston at gcc dot gnu.org --- Patch in comment 1 produces: z1.f90 -> pr93714_1.f90 pr93714_1.f90:3:4: 3 |character, pointer :: b => a |1 Error: Unclassifiable statement at (1) pr93714_1.f90:2:13: 2 |character((1.)) :: a | 1 Error: Expression at (1) must be of INTEGER type, found REAL z2.f90 -> pr93714_1.f90 pr93714_2.f90:3:4: 3 |character(:), pointer :: b => a |1 Error: Unclassifiable statement at (1) pr93714_2.f90:2:13: 2 |character((9.)), target :: a | 1 Error: Expression at (1) must be of INTEGER type, found REAL Can do better than "Unclassifiable statement". Moving the check for lvalue being a character to after the handling of pointer and target attributes: diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index a9698c3e3d2..79e00b4112a 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -4222,13 +4222,6 @@ gfc_check_pointer_assign (gfc_expr *lvalue, gfc_expr *rvalue, if (rvalue->expr_type == EXPR_NULL) return true; - if (lvalue->ts.type == BT_CHARACTER) -{ - bool t = gfc_check_same_strlen (lvalue, rvalue, "pointer assignment"); - if (!t) - return false; -} - if (rvalue->expr_type == EXPR_VARIABLE && is_subref_array (rvalue)) lvalue->symtree->n.sym->attr.subref_array_pointer = 1; @@ -4284,6 +4277,13 @@ gfc_check_pointer_assign (gfc_expr *lvalue, gfc_expr *rvalue, } } + if (lvalue->ts.type == BT_CHARACTER) +{ + bool t = gfc_check_same_strlen (lvalue, rvalue, "pointer assignment"); + if (!t) + return false; +} + if (is_pure && gfc_impure_variable (rvalue->symtree->n.sym)) { gfc_error ("Bad target in pointer assignment in PURE " and omitting Steve Kargl's patch results in: pr93714_1.f90:3:31: 3 |character, pointer :: b => a | 1 Error: Pointer assignment target in initialization expression does not have the TARGET attribute at (1) pr93714_1.f90:2:13: 2 |character((1.)) :: a | 1 Error: Expression at (1) must be of INTEGER type, found REAL and pr93714_2.f90:3:34: 3 |character(:), pointer :: b => a | 1 Error: Pointer assignment target in initialization expression does not have the TARGET attribute at (1) pr93714_2.f90:2:13: 2 |character((9.)) :: a | 1 Error: Expression at (1) must be of INTEGER type, found REAL Running make with check-fortran resulted in char_pointer_assign_6.f90 failing: char_pointer_assign_6.f90:8:2: 8 | p1 => s1(2:3) ! { dg-error "Unequal character lengths \\(20/2\\)" } | 1 Error: Unequal character lengths (20/2) in pointer assignment at (1) char_pointer_assign_6.f90:9:8: 9 | p1 => c(1:) ! { dg-error "Unequal character lengths \\(20/4\\)" } |1 Error: Pointer assignment target is neither TARGET nor POINTER at (1) char_pointer_assign_6.f90:10:8: 10 | p1 => c(:4) ! { dg-error "Unequal character lengths \\(20/4\\)" } |1 Error: Pointer assignment target is neither TARGET nor POINTER at (1) The variable c does not have the target attribute so the unequal character lengths messages should not have occurred. I'm now modifying char_pointer_assign_6.f90 and adding test cases so I can send a patch upstream for approval.
[Bug fortran/93714] [8/9/10 Regression] ICE in gfc_check_same_strlen, at fortran/check.c:1253
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93714 Richard Biener changed: What|Removed |Added Target Milestone|--- |8.4
[Bug fortran/93714] [8/9/10 Regression] ICE in gfc_check_same_strlen, at fortran/check.c:1253
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93714 kargl at gcc dot gnu.org changed: What|Removed |Added Priority|P3 |P4 Status|UNCONFIRMED |NEW Last reconfirmed||2020-02-12 CC||kargl at gcc dot gnu.org Ever confirmed|0 |1 Known to fail||10.0, 8.3.1, 9.2.1 --- Comment #1 from kargl at gcc dot gnu.org --- Diff is against svn r280157. Index: gcc/fortran/check.c === --- gcc/fortran/check.c (revision 280157) +++ gcc/fortran/check.c (working copy) @@ -1244,8 +1244,14 @@ gfc_check_same_strlen (const gfc_expr *a, const gfc_ex { long len_a, len_b; - len_a = gfc_var_strlen(a); - len_b = gfc_var_strlen(b); + if ((a->ts.u.cl && a->ts.u.cl->length +&& a->ts.u.cl->length->ts.type != BT_INTEGER) + || (b->ts.u.cl && b->ts.u.cl->length +&& b->ts.u.cl->length->ts.type != BT_INTEGER)) + return false; + + len_a = gfc_var_strlen (a); + len_b = gfc_var_strlen (b); if (len_a == -1 || len_b == -1 || len_a == len_b) return true;