When compiling the attached program (-std=c99 -march=i486 -O?), GCC allocates the following stacks for the recursive function "f" (in bytes):
GCC 3.4.5 (20050821) -O2: 16 -O3: 16 GCC 4.0.2 (20050917) -O2: 40 -O3: 360 (!) GCC 4.1.0 (20050904) -O2: 28 -O3: 28 There are only 10 local int variables in the function, so the 360-byte consumption with GCC 4.0.2 seems a bit high, with respect to the 16 bytes with GCC 3.4.5. Especially since the code actually runs 25% slower when compiled with 4.0.2 whatever the optimization level (17% with 4.1.0). -- Summary: Excessive (x20) stack usage for 4.0 with -O3 Product: gcc Version: 4.0.2 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: guillaume dot melquiond at ens-lyon dot fr CC: gcc-bugs at gcc dot gnu dot org GCC target triplet: i486-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24020