public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.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	[thread overview]
Message-ID: <bug-94769-4-PswXXfAZ8v@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-94769-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94769

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Stefan Schulze Frielinghaus
<stefansf@gcc.gnu.org>:

https://gcc.gnu.org/g:27594524d8a93cddb197ad8c9d4075c5870f1473

commit r10-8053-g27594524d8a93cddb197ad8c9d4075c5870f1473
Author: Stefan Schulze Frielinghaus <stefansf@linux.ibm.com>
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=maybe-uninitialized]
     3857 |       if (num == 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 the
    particular call side), and WARN equals true, then the function returns with
a
    non-zero value and leaves num uninitialized which renders the warning true.

    Initialized num to -1 and added an assert statement.

    gcc/fortran/ChangeLog:

    2020-04-29  Stefan Schulze Frielinghaus  <stefansf@linux.ibm.com>

            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.

  parent reply	other threads:[~2020-04-29 14:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-26  8:31 [Bug fortran/94769] New: " stefansf at linux dot ibm.com
2020-04-26 16:56 ` [Bug fortran/94769] " kargl at gcc dot gnu.org
2020-04-26 17:10 ` schwab@linux-m68k.org
2020-04-27  6:27 ` stefansf at linux dot ibm.com
2020-04-27 16:07 ` sgk at troutmask dot apl.washington.edu
2020-04-27 17:12 ` tkoenig at gcc dot gnu.org
2020-04-27 17:37 ` sgk at troutmask dot apl.washington.edu
2020-04-27 18:05 ` stefansf at linux dot ibm.com
2020-04-28 12:01 ` stefansf at linux dot ibm.com
2020-04-29 14:41 ` cvs-commit at gcc dot gnu.org [this message]
2020-04-30  9:32 ` stefansf at linux dot ibm.com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-94769-4-PswXXfAZ8v@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).