https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113164
Bug ID: 113164 Summary: [missed optimization] struct fields should not alias Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: powerboat9.gamer at gmail dot com Target Milestone: --- I have the following code > struct sss { > int a; > int b; > }; > > int foo(struct sss *a, struct sss *b) { > return &a->a == &b->b; > } When I compile it with > gcc -c -O3 -Wall -Wextra test.c I get > 0000000000000000 <foo>: > 0: 48 83 c6 04 add $0x4,%rsi > 4: 31 c0 xor %eax,%eax > 6: 48 39 fe cmp %rdi,%rsi > 9: 0f 94 c0 sete %al > c: c3 ret , but GCC should be able to infer that the two pointers being compared can not alias.