From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 00CDE395B04E; Wed, 29 Apr 2020 14:41:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 00CDE395B04E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1588171271; bh=dIYP9xOfJcRvcNsjemH8LG+sv/8H0KxeGhgfbxMPv2Y=; h=From:To:Subject:Date:In-Reply-To:References:From; b=DtP4owq+kCk+Fr6Pg7Cgyt+vrGZ/ZDIlT4gae0xU8ng+tJ3s2WOnE3fUQIf9gSbUC JyP+eQJO1aBdoBH1pJpJ9H75ZbNq2SlXBgZf5R/MFSfuxp8iIrX+p88yJvGCQDbng1 Rll4Ilujgze41G65fj+eWJdB/rnQml4IuHDd6GMA= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/94769] Possible use of uninitialized variable num Date: Wed, 29 Apr 2020 14:41:10 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org 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: Message-ID: In-Reply-To: References: 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, 29 Apr 2020 14:41:11 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94769 --- Comment #9 from CVS Commits --- The master branch has been updated by Stefan Schulze Frielinghaus : https://gcc.gnu.org/g:27594524d8a93cddb197ad8c9d4075c5870f1473 commit r10-8053-g27594524d8a93cddb197ad8c9d4075c5870f1473 Author: Stefan Schulze Frielinghaus Date: Tue Apr 28 13:14:28 2020 +0200 fortran/io.c: Fix use of uninitialized variable num [PR94769] While bootstrapping GCC on S/390 the following warning occurs: gcc/fortran/io.c: In function 'bool gfc_resolve_dt(gfc_code*, gfc_dt*, locus*)': gcc/fortran/io.c:3857:7: error: 'num' may be used uninitialized in this function [-Werror=3Dmaybe-uninitialized] 3857 | if (num =3D=3D 0) | ^~ gcc/fortran/io.c:3843:11: note: 'num' was declared here 3843 | int num; Since gfc_resolve_dt is a non-static function we cannot assume anything about argument DT. Argument DT gets passed to function check_io_constraints which passes values depending on DT, namely dt->asynchronous->value.character.string to function compare_to_allowed_values as well as argument warn which is true as soon as DT->dterr is true. Thus both arguments depend on DT. If function compare_to_allowed_values is called with dt->asynchronous->value.character.string not being an allowed value, and ALLOWED_F2003 as well as ALLOWED_GNU being NULL (which is the case at t= he particular call side), and WARN equals true, then the function returns = with a non-zero value and leaves num uninitialized which renders the warning t= rue. Initialized num to -1 and added an assert statement. gcc/fortran/ChangeLog: 2020-04-29 Stefan Schulze Frielinghaus PR fortran/94769 * io.c (check_io_constraints): Initialize local variable num to -1 and assert that it receives a meaningful value by function compare_to_allowed_values.=