From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1EA27388A829; Wed, 3 Jun 2020 19:46:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1EA27388A829 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1591213594; bh=QCEROc5Lp2Wa3R8oLB6Qqcv23PJtoP2QFKBgR0kTe1Y=; h=From:To:Subject:Date:From; b=SlS21Cr8LYV90EumTbneAqnLU9bR7qx5gsAlTaIhEuWTS4yi7K8xJlwpYjNPCjIvI Dy4/83bZUEWk6sYC0+N0Pl4S1GzVvvn0k0aJTDJNUssxwmg6pDHXEIUJRFY9B/V+ox hPhppkxDHuXYrv2FhoOakAb8Dnm2N5OBn0+Nw4Mw= From: "dcb314 at hotmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/95512] New: gcc/fortran/trans-decl.c:1066: array sanity check after use Date: Wed, 03 Jun 2020 19:46:33 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dcb314 at hotmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Jun 2020 19:46:34 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95512 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= .=20 */ if (GFC_TYPE_ARRAY_UBOUND (type, dim) =3D=3D 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= .=20 */ if (dim < GFC_TYPE_ARRAY_RANK (type) + GFC_TYPE_ARRAY_CORANK (type) -= 1 && GFC_TYPE_ARRAY_UBOUND (type, dim) =3D=3D NULL_TREE)=