3 ms·
> Example: you pass an object by value, and only read one field, can it optimize this? Yes. struct S { int a,b; }; void foo(int); // Some external fun
by mike_hock 10y ago
> Example: you pass an object by value, and only read one field, can it optimize this?
Yes.
struct S { int a,b; };
void foo(int); // Some external function
void bar(S s) { foo(s.a); }
void baz() { bar(S{42, 55}); }
compiles the baz function to (-O2 on GCC 4.9)
movl $42, %edi
jmp _Z3fooi