Let's say I compile the following with GCC 5.4 with -O2
or -O3
level of optimization.
typedef struct {
int data[90];
} huge_t;
int foo( const huge_t bar );
// ...
huge_t x = { 0 };
foo(x);
Here, I would venture to say is not necessary to create a second copy of x
on the stack because foo
is not (supposed to be) modifying its argument. (When) will GCC come to the same conclusion?
In other words, is it ok for me to work with const
arguments of type huge_t
for convenience, or should I be using pointers? I could imagine both versions being "good style" in one sense or the other and would very much appreciate an informed opinion.