From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1121 invoked by alias); 21 Nov 2007 11:05:33 -0000 Received: (qmail 1096 invoked by uid 48); 21 Nov 2007 11:05:22 -0000 Date: Wed, 21 Nov 2007 11:05:00 -0000 Message-ID: <20071121110522.1095.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug target/34161] -Os produces 32-bit load from 16-bit variable In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "vegard at peltkore dot net" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-11/txt/msg01965.txt.bz2 ------- 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