https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95512
Bug ID: 95512 Summary: gcc/fortran/trans-decl.c:1066: array sanity check after use Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: dcb314 at hotmail dot com Target Milestone: --- Static analyser cppcheck says: gcc/fortran/trans-decl.c:1066:11: style: Array index 'dim' is used before limits check. [arrayIndexThenCheck] Source code is /* Don't try to use the unknown ubound for the last coarray dimension. */ if (GFC_TYPE_ARRAY_UBOUND (type, dim) == NULL_TREE && dim < GFC_TYPE_ARRAY_RANK (type) + GFC_TYPE_ARRAY_CORANK (type) - 1) Maybe better code: /* Don't try to use the unknown ubound for the last coarray dimension. */ if (dim < GFC_TYPE_ARRAY_RANK (type) + GFC_TYPE_ARRAY_CORANK (type) - 1 && GFC_TYPE_ARRAY_UBOUND (type, dim) == NULL_TREE)