[PATCH] Do not warn with warn_unused_result for alloca(0).

Jeff Law law@redhat.com
Thu Jun 13 15:49:00 GMT 2019

On 6/12/19 10:40 AM, Jakub Jelinek wrote:
> On Wed, Jun 12, 2019 at 10:13:57AM -0600, Martin Sebor wrote:
>> But GCC doesn't support such an implementation, does it?
> Why would that be relevant?  The warning would cause people to make portable
> code less portable (by removing the alloca (0) calls that were added there
> for portability reasons), or add hacks to work around the warning (whether
> #pragma GCC diagnostic or something else).  That is something we do not
> want people to do.
I'd like to move C-alloca support to the ash heap of history.  But I'm
not sure we can realistically do that.  Given that reality I think we
need to honor the intent of alloca(0).

I also understand Martin's point that not warning on it could easily
miss programming errors.

I wonder if we could set TREE_NOWARNING on the CALL_EXPR early in the
front-end of the argument is a constant 0 (before simplification,
folding, etc).

That way we'd be able to support alloca(0), but also capture cases where
0 flows into alloca via other mechansisms (which are likely programming


More information about the Gcc-patches mailing list