public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "miyuki at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/55035] reload1.c:3766:41: error: ‘orig_dup[0]’ may be used uninitialized in this function (for fr30, microblaze, moxie, rl78)
Date: Wed, 20 May 2015 01:06:00 -0000	[thread overview]
Message-ID: <bug-55035-4-ezr5gGAXWK@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-55035-4@http.gcc.gnu.org/bugzilla/>

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

Mikhail Maltsev <miyuki at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2015-04-09 00:00:00         |2015-5-20
                 CC|                            |miyuki at gcc dot gnu.org
      Known to fail|                            |6.0

--- Comment #5 from Mikhail Maltsev <miyuki at gcc dot gnu.org> ---
Reduced testcase:

$ cat ./warn2.cc
int arr[1];
int N;

void bar();

void foo()
{
  int temp[2];
  for (int i = 0; i < N; i++)
    temp[i] = arr[i];
  bar();
  for (int i = 0; i < N; i++)
    arr[i] = temp[i];
}


$ /opt/gcc-6.0.0/bin/g++ -c -Wall -O2 -fdump-tree-all ./warn2.cc
./warn2.cc: In function 'void foo()':
./warn2.cc:13:21: warning: 'temp[0]' may be used uninitialized in this function
[-Wmaybe-uninitialized]
     arr[i] = temp[i];

$ /opt/gcc-6.0.0/bin/g++ -c -Wall -O2 -fno-tree-sra ./warn2.cc
(no warning)

GCC performs scalar replacement of "temp" and unrolls both loops. N is global
and can be modified by bar(). The final GIMPLE looks like this:

$ cat ./warn2.cc.190t.optimized

void foo() ()
{
  int temp$0;
  int N.0_18;
  int N.0_24;

  <bb 2>:
  N.0_24 = N;
  if (N.0_24 <= 0)
    goto <bb 4>;
  else
    goto <bb 3>;

  <bb 3>:
  temp$0_25 = arr[0];

  <bb 4>:
  # temp$0_26 = PHI <temp$0_25(3), temp$0_27(D)(2)>
  bar ();
  N.0_18 = N;
  if (N.0_18 <= 0)
    goto <bb 6>;
  else
    goto <bb 5>;

  <bb 5>:
  arr[0] = temp$0_26;

  <bb 6>:
  return;
}

Here temp$0_27(D)(2) is the "uninitialized" case. In the original testcase
recog_data.n_dups is considered escaped and orig_dup[0] is treated the same way
as temp[0].


  parent reply	other threads:[~2015-05-20  1:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-23 14:23 [Bug middle-end/55035] New: reload1.c:3766:41: error: ‘orig_dup[0]’ may be used uninitialized in this function (for fr30, microblaze) amylaar at gcc dot gnu.org
2014-07-27 22:29 ` [Bug middle-end/55035] reload1.c:3766:41: error: ‘orig_dup[0]’ may be used uninitialized in this function (for fr30, microblaze, moxie, rl78) hp at gcc dot gnu.org
2014-07-27 22:31 ` hp at gcc dot gnu.org
2014-07-29 11:05 ` hp at gcc dot gnu.org
2015-04-09 19:16 ` aldot at gcc dot gnu.org
2015-05-20  1:06 ` miyuki at gcc dot gnu.org [this message]
2015-07-26  8:57 ` miyuki at gcc dot gnu.org
2015-07-27 15:43 ` law at redhat dot com
2015-08-13 20:23 ` rsandifo at gcc dot gnu.org
2015-08-26  7:28 ` ro at gcc dot gnu.org
2015-09-09  0:36 ` hp 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-55035-4-ezr5gGAXWK@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).