This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/22129] Optimization stomps const, initialized local array
- From: "cnewbold at mathworks dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Jun 2005 20:47:01 -0000
- Subject: [Bug rtl-optimization/22129] Optimization stomps const, initialized local array
- References: <20050620202450.22129.cnewbold@mathworks.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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