This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/34161] -Os produces 32-bit load from 16-bit variable
- From: "vegard at peltkore dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Nov 2007 11:05:22 -0000
- Subject: [Bug target/34161] -Os produces 32-bit load from 16-bit variable
- References: <bug-34161-14028@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from vegard at peltkore dot net 2007-11-21 11:05 -------
It can trigger watchpoints on other members. Try this example:
struct s {
int dummy;
short x;
short y;
};
void dummy(struct s *b) { }
void f(struct s *a, struct s *b) {
dummy(b);
if (a)
b->x = a->x;
}
static struct s x;
static struct s y;
int
main()
{
f(&x, &y);
return 0;
}
That code never touches the y member of struct s. Yet when we run this in GDB,
we get this:
(gdb) rwatch x.y
Hardware read watchpoint 1: x.y
(gdb) run
Starting program: .../a.out
Hardware read watchpoint 1: x.y
Value = 0
0x080483c2 in main () at movzwl.c:17
17 b->x = a->x;
And this doesn't really make that much sense unless you know what's going on.
I'd say that following the principle of least surprise, this optimization is
unfortunate at the very least.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34161