------- 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

Reply via email to