Re: why not optimize static local variables

2023-10-09 Thread Richard Biener via Gcc
On Sat, Oct 7, 2023 at 3:08 PM Hanke Zhang via Gcc wrote: > > Hi, I've recently been working on static local variables in C. I would > like to ask about some questions about that. > > For example, for the following program, > > void foo() { > static int x = 0; > x++; > } > > int main() { > f

why not optimize static local variables

2023-10-07 Thread Hanke Zhang via Gcc
Hi, I've recently been working on static local variables in C. I would like to ask about some questions about that. For example, for the following program, void foo() { static int x = 0; x++; } int main() { foo(); } After optimization with the -O3 -flto option, the entire program will loo