Liste des Groupes | Revenir à c arch |
On Sun, 15 Sep 2024 18:47:06 -0700
Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
>Michael S <already5chosen@yahoo.com> writes:>
>On Sun, 15 Sep 2024 20:13:44 +0200>
David Brown <david.brown@hesbynett.no> wrote:
>struct Bar {>
char x[8];
int y;
} bar;
>
>
int foo(int i) {
bar.y = 1234;
bar.x[i] = 42;
return bar.y;
}
>
It generates:
>
foo:
movslq %edi,%rdi
movl $1234, %eax
movl $1234, bar+8(%rip)
movb $42, bar(%rdi)
ret
>
That is, y is /not/ reloaded after bar.x[i] is set.
No other compiler on godbolt is doing it, except possibly gcc
clones. Not even clang, who's former leader wrote "Nasal Manifest".
Test runs on two different Ubuntu machines (gcc 7.4.0 and gcc 8.4.0)
both show bar.y not being overwritten (optimization levels -01 or -O2)
when foo() is called.
I didn't mean to say that gcc3 is the only gcc version that returns
non-overwritten value.
I meant to say that all gcc versions are in one camp and the rest of
compilers represented on Goldbolt is in the other camp.
Les messages affichés proviennent d'usenet.