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 middle-end/107411] trivial-auto-var-init=zero invalid uninitialized variable warning
Date: Tue, 28 Feb 2023 17:11:31 +0000	[thread overview]
Message-ID: <bug-107411-4-EN19Hwl1Nt@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107411-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #14 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Qing Zhao <qinzhao@gcc.gnu.org>:

https://gcc.gnu.org/g:afe6cea4489846aa8585f3c045d16cdaa08cc6cd

commit r13-6379-gafe6cea4489846aa8585f3c045d16cdaa08cc6cd
Author: Qing Zhao <qing.zhao@oracle.com>
Date:   Tue Feb 28 17:11:05 2023 +0000

    Fixing PR107411

    This is a bug in tree-ssa-uninit.cc.
    When doing the following:

      /* Ignore the call to .DEFERRED_INIT that define the original
         var itself as the following case:
           temp = .DEFERRED_INIT (4, 2, âalt_reloc");
           alt_reloc = temp;
         In order to avoid generating warning for the fake usage
         at alt_reloc = temp.
      */

    We need to compare the var name inside the .DEFERRED_INIT call
    (the 3rd argument) and the name for the LHS variable. if they are the same,
    we will NOT report the warning.

    There is one issue when we get the name for the LHS variable. when the
    variable doesn't have a DECL_NAME (it's not a user declared variable,
    which is the case for this bug):

      _1 = .DEFERRED_INIT (4, 2, &"D.2389"[0]);
      D.2389 = _1;

    The current checking just ignores this case, and still report the warning.

    The fix is very simple, when getting the name for the LHS variable, we
should
    consider this case and come up with the name the same way as we construct
the
    3rd argument for the call to .DEFERRED_INIT (please refer to the routine
    "gimple_add_init_for_auto_var")

            PR middle-end/107411

    gcc/ChangeLog:

            PR middle-end/107411
            * gimplify.cc (gimple_add_init_for_auto_var): Use sprintf to
replace
            xasprintf.
            * tree-ssa-uninit.cc (warn_uninit): Handle the case when the
            LHS varaible of a .DEFERRED_INIT call doesn't have a DECL_NAME.

    gcc/testsuite/ChangeLog:

            PR middle-end/107411
            * g++.dg/pr107411.C: New test.

  parent reply	other threads:[~2023-02-28 17:11 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-26  9:10 [Bug c++/107411] New: " davidwelch158 at hotmail dot com
2022-10-26 17:52 ` [Bug middle-end/107411] " pinskia at gcc dot gnu.org
2022-10-28 11:31 ` rguenth at gcc dot gnu.org
2022-10-28 14:15 ` qinzhao at gcc dot gnu.org
2022-11-21 15:35 ` pinskia at gcc dot gnu.org
2023-02-14  0:03 ` pinskia at gcc dot gnu.org
2023-02-15 19:21 ` qinzhao at gcc dot gnu.org
2023-02-16  7:35 ` rguenther at suse dot de
2023-02-16 14:30 ` qing.zhao at oracle dot com
2023-02-16 20:18 ` qinzhao at gcc dot gnu.org
2023-02-16 20:18 ` qinzhao at gcc dot gnu.org
2023-02-16 20:55 ` jakub at gcc dot gnu.org
2023-02-16 21:53 ` qinzhao at gcc dot gnu.org
2023-02-17  7:32 ` rguenther at suse dot de
2023-02-28 17:11 ` cvs-commit at gcc dot gnu.org [this message]
2023-02-28 17:13 ` qinzhao at gcc dot gnu.org

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-107411-4-EN19Hwl1Nt@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).