public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cnewbold at mathworks dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/22129] Optimization stomps const, initialized local array
Date: Mon, 20 Jun 2005 20:47:00 -0000	[thread overview]
Message-ID: <20050620204701.3419.qmail@sourceware.org> (raw)
In-Reply-To: <20050620202450.22129.cnewbold@mathworks.com>


------- Additional Comments From cnewbold at mathworks dot com  2005-06-20 20:46 -------
Subject: Re:  Optimization stomps const,
	initialized local array

On Mon, 2005-06-20 at 20:39 +0000, pinskia at gcc dot gnu dot org wrote:

> I don't see the problem on the mainline, maybe I not understanding what you mean.

The problem is that once we're past the initialization and into the body
of the block, the array does not have the correct content. In the
example I cited, the first byte of 'encrypted' does not contain 0xf3,
but instead some random trash. Here's a break down of the assembler for
the opening of that block:

First byte of 'encrypted' (correctly) loaded with 0xf3:
    2cab:       c6 85 08 ff ff ff f3    movb   $0xf3,0xffffff08(%ebp)

Something else dropped in here, which stomps the first element:
    2cb2:       ba 08 00 00 00          mov    $0x8,%edx
    2cb7:       b9 08 00 00 00          mov    $0x8,%ecx
    2cbc:       89 95 08 ff ff ff       mov    %edx,0xffffff08(%ebp)
                                               ^^^^^^^^^^^^^^^^
                                                  OOOPS!
    2cc2:       31 c0                   xor    %eax,%eax
    2cc4:       8d 55 b8                lea    0xffffffb8(%ebp),%edx
    2cc7:       89 8d 28 ff ff ff       mov    %ecx,0xffffff28(%ebp)
    2ccd:       8d 8d 30 ff ff ff       lea    0xffffff30(%ebp),%ecx

Remaining 23 bytes of 'encrypted' are loaded:
    2cd3:       c6 85 09 ff ff ff 09    movb   $0x9,0xffffff09(%ebp)
    2cda:       c6 85 0a ff ff ff 62    movb   $0x62,0xffffff0a(%ebp)
    ...

-Chris


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22129


  parent reply	other threads:[~2005-06-20 20:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-20 20:25 [Bug c++/22129] New: " cnewbold at mathworks dot com
2005-06-20 20:26 ` [Bug c++/22129] " cnewbold at mathworks dot com
2005-06-20 20:36 ` cnewbold at mathworks dot com
2005-06-20 20:39 ` [Bug rtl-optimization/22129] " pinskia at gcc dot gnu dot org
2005-06-20 20:47 ` cnewbold at mathworks dot com [this message]
2005-06-20 20:48 ` [Bug rtl-optimization/22129] [3.4 only] " pinskia at gcc dot gnu dot org
2005-06-20 20:51 ` cnewbold at mathworks dot com
2005-06-21 15:51 ` cnewbold at mathworks dot com
2005-07-27 12:50 ` rsandifo at gcc dot gnu dot 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=20050620204701.3419.qmail@sourceware.org \
    --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).