Bug 810564 - gcc with -fexceptions and no -O increases stack usage by local variables
gcc with -fexceptions and no -O increases stack usage by local variables
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
17
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Jakub Jelinek
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-04-06 14:00 EDT by Laine Stump
Modified: 2012-04-06 15:00 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-04-06 15:00:25 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Laine Stump 2012-04-06 14:00:40 EDT
Description of problem: When Fedora 17's gcc is run with:

   -Wframe-larger-than=4096 -Werror -fexceptions

on some files that compiled without error in Fedora 16 (gcc-4.6.3-2), it fails with, e.g.:

   test.c: In function ‘main’:
   test.c:20:4: error: the frame size of 6016 bytes is larger than 4096 bytes
   [-Werror=frame-larger-than=]


Version-Release number of selected component (if applicable):
gcc-4.7.0-1.fc17.x86_64

How reproducible: 100%


Steps to Reproduce:

1) Put this small program into /tmp/test.c:

#include <stdio.h>
void main()
   {
   char test1[1];
      {
      char test2[3000];
      printf(test2);
      }
      {
      char test3[3000];
      printf(test3);
      }
   }

2) cc -Wframe-larger-than=4096 -Werror -fexceptions /tmp/test.c
  
Actual results:

/tmp/test.c: In function ‘main’:
/tmp/test.c:15:4: error: the frame size of 6016 bytes is larger than 4096 bytes [-Werror=frame-larger-than=]
cc1: all warnings being treated as errors

Expected results:

Should exit silently (and does so when run on Fedora 16)

Additional info:

    1) adding -O<anything-but-0> eliminates the failure
    1) removing -fexceptions eliminates the failure
    2) removing "char test1[1];" from main() also eliminates the failure
    3) even changing "char test1[1];" to "char test1;" eliminates the failure

Apparently when all of the above conditions are set just right, gcc now doesn't reuse stack space, while it previously did. This is causing build failures of applications that used to build; while the failures can be remedied, it is annoying and a regression in efficient use of the stack.
Comment 1 Jakub Jelinek 2012-04-06 15:00:25 EDT
This is a user error, if you need small stack frames, you just shouldn't use -O0.  -O0 is mainly for fast compilation and debuggability, and stack sharing is quite compile time consuming.

Note You need to log in before you can comment on or make changes to this bug.