https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70232
Bug ID: 70232 Summary: excessive stack usage with -O2 Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: arnd at linaro dot org Target Milestone: --- Created attachment 37964 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37964&action=edit partially reduced test case Using gcc-6.0 for building the Linux kernel, I see one file (out of many hundred randconfig test builds so far) that occasionally hits the maximum per-function stack size limit. I have only tested on 32-bit ARM, and I have manually reduced the test case: $ arm-linux-gnueabi-gcc -o lpfc_scsi.o -O2 -Wframe-larger-than=1024 lpfc_scsi.c: In function 'lpfc_find_next_oas_lun': lpfc_scsi.c:117:1: warning: the frame size of 1152 bytes is larger than 1024 bytes [-Wframe-larger-than=] $ arm-linux-gnueabi-gcc --version arm-linux-gnueabi-gcc (GCC) 6.0.0 20160313 (experimental) I see this with all options as long as -O2 is set, but not with -O3 or -O1 or -Os. Normal stack usage for this function is usually 128 bytes.