$ cat tmp.c struct some_struct { int i; int j; void* priv[]; }; struct some_struct_priv { int k; int l; }; void update( struct some_struct* s ) { s->i = 0; s->j = 0; struct some_struct_priv* priv = (struct some_struct_priv*)s->priv; #ifdef TEST priv->k = 0; #endif priv->l = 0; }
$ gcc -Wall tmp.c -c -O2 -fno-strict-aliasing && objdump -d tmp.o 0000000000000000 <update>: 0: c7 07 00 00 00 00 movl $0x0,(%rdi) 6: c7 47 04 00 00 00 00 movl $0x0,0x4(%rdi) d: c7 47 0c 00 00 00 00 movl $0x0,0xc(%rdi) 14: c3 retq $ gcc -Wall tmp.c -c -O2 -fno-strict-aliasing -DTEST && objdump -d tmp.o 0000000000000000 <update>: 0: c7 07 00 00 00 00 movl $0x0,(%rdi) 6: c7 47 04 00 00 00 00 movl $0x0,0x4(%rdi) d: 48 83 c7 08 add $0x8,%rdi <== [*] 11: c7 07 00 00 00 00 movl $0x0,(%rdi) <== [*] 17: c7 47 04 00 00 00 00 movl $0x0,0x4(%rdi) <== [*] 1e: c3 retq [*] could be done with: movl $0, 8(%rdi); movl $0, 12(%rdi). -- Summary: unoptimal addressing mode. Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: pluto at agmk dot net GCC target triplet: x86_64-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29124