Have a look at this tiny snippet of C code or C++ code on godbolt...
void b( char const *c);
void a(void)
{
char const z[] = {0xd, 0xe, 0xa, 0xd, 0xb, 0xe, 0xe, 0xf, 0xa};
b(z);
}
void c(void)
{
static char const z[] = {0xd, 0xe, 0xa, 0xd, 0xb, 0xe, 0xe, 0xf, 0xa};
b(z);
}
Earlier versions of gcc compiles both a() and c() to two instructions, load address of z, jump to b.
All modern compilers I tried "pessimise" a() to "make stack frame, copy z onto stack, call b, tear down stack frame, but leave c() as the two instruction simple version.
In effect nothing has changed, in practice modern compilers are now slower for this use case.....
Anybody have any idea why?