http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35561
Steven Fuerst <svfuerst at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |svfuerst at gmail dot com --- Comment #6 from Steven Fuerst <svfuerst at gmail dot com> 2011-06-23 03:14:13 UTC --- Still a problem in 4.6 at all optimization levels. int foo1(int x) { int a[] = {1,4,7,9}; return a[x]; } int foo2(int x) { static int a[] = {1,4,7,9}; return a[x]; } foo1() creates the array on the stack using a series of mov instructions, whereas the code generated for foo2() is much nicer.