Open
Description
Take:
struct f {
int a[1024];
};
void g();
struct f hh();
struct f h(float *fp) {
struct f a;
a = hh();
struct f b = a;
g();
*fp = 1;
a = b;
return a;
}
struct f h1(float *fp) {
struct f a = hh();
struct f b = a;
g();
*fp = 1;
a = b;
return a;
}
These 2 functions should produce the exact same code generation. The only difference between then is where the assignment to a happens; on the decl initializer or outside of it.
h produces better code generation than h1; h1 has 2 calls to memcpy while h has 0.
https://godbolt.org/z/GfMq96rTY for reference.