https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115632
Bug ID: 115632 Summary: resolve.cc: FORALL check function is has wrong-code bugs Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org Target Milestone: --- The following doesn't make sense on multiple ways: (A) ----------------- find_forall_index (gfc_expr *expr, gfc_symbol *sym, int f) { if (gfc_traverse_expr (expr, sym, forall_index, f)) ----------------- The function takes as last argument a POINTER; if the return value is not needed, passing '&f' would do – otherwise, 'int f' should be 'int *f' in the parameter list. (B) ----------------- static bool forall_index (gfc_expr *expr, gfc_symbol *sym, int *f) { ----------------- The cleaner & more explicit solution is: forall_index (gfc_expr *expr, gfc_symbol *sym, void *f2) { int *f = (int *) f2; (C) /* A scalar assignment */ if (!expr->ref || *f == 1) I don't understand the comment about 'assignment'. (D) /* .... f == 2 signals that that variable itself is not to be checked - only the references. */ ... if (*f == 2) *f = 1; This one looks completely bogus. Callers: resolve.cc - those seem to be fine at a glance: if (find_forall_index (iter2->start, iter->var->symtree->n.sym, 0) || find_forall_index (iter2->end, iter->var->symtree->n.sym, 0) || find_forall_index (iter2->stride, iter->var->symtree->n.sym, 0)) if (!find_forall_index (code->expr1, forall_index, 0)) trans-stmt.cc - but this one is really bogus: new_symtree = NULL; if (find_forall_index (c->expr1, lsym, 2)) { forall_make_variable_temp (c, pre, post); need_temp = 0; } The '2' definitely doesn't do what was advertised here … * * * Note: the forall index is a 'scalar integer name', i.e. there are not many possibilies for 'ref->', ignoring, e.g., 'idx%kind' which should be fine.