https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82365
Bug ID: 82365 Summary: excessive stack usage with norreturn attribute Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other Assignee: unassigned at gcc dot gnu.org Reporter: clyon at gcc dot gnu.org Target Milestone: --- Created attachment 42264 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42264&action=edit testcase We have noticed that gcc fails to reuse stack locations in presence of noreturn attribute in the call graph. Basically, the attached testcase has case 1: { struct XXX localvar; bla1; break; } case 2: { struct XXX localvar; bla2; break; } case 3: { struct XXX localvar; bal3; break; } With noreturn attribute: aarch64-linux-gnu-gcc -Wall -O2 -S bz-3265.c --param asan-stack=1 -Wframe-larger-than=1 bz-3265.c: In function ‘em28xx_dvb_init’: bz-3265.c:99:1: warning: the frame size of 480 bytes is larger than 1 bytes [-Wframe-larger-than=] Without noreturn attribute: aarch64-linux-gnu-gcc -Wall -O2 -S bz-3265.c --param asan-stack=1 -Wframe-larger-than=1 -DNONORETURN bz-3265.c: In function ‘em28xx_dvb_init’: bz-3265.c:99:1: warning: the frame size of 128 bytes is larger than 1 bytes [-Wframe-larger-than=] The code fragment is extracted from the linux kernel where this causes more problems with using -fsanitize=kernel-address, where this causes excessive stack usage. I used an aarch64 compiler here, but Arnd observed similar problems on x86_64 too.