https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98055
Bug ID: 98055 Summary: __builtin_alloca should not have warn_unused_result attribute Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: psmith at gnu dot org Target Milestone: --- Code that wants to use alloca() and still be portable will often include replacements where memory is allocated on the heap, and the user is expected to invoke alloca(0) periodically to free up this memory. See for example the GNU gnulib replacement alloca(). (Please no comments about the usefulness or not of alloca()--I'm not interested in that discussion. alloca() has problems but it's strictly more powerful than VLAs, while providing the possibility of portability to compilers that don't support them). In this situation (invoking alloca(0)) there's no point in assigning the return value, and older versions of GCC this works fine but when I try to compile the same code with GCC 10.2.0 compilation fails because apparently __builtin_alloca() now has the warn_unused_result attribute applied to it (this isn't documented anywhere that I can find, but appears to be the case): In file included from src/makeint.h:31, from src/read.c:17: src/read.c: In function 'eval_makefile': lib/alloca.h:46:18: error: ignoring return value of '__builtin_alloca' declared with attribute 'warn_unused_result' [-Werror=unused-result] 46 | # define alloca __builtin_alloca src/read.c:435:3: note: in expansion of macro 'alloca' 435 | alloca (0); | ^~~~~~ Because (void) doesn't work around this attribute there's no easy way to resolve this; I don't think it's appropriate to add this attribute to alloca() and it should be removed.